Laravel - Validation - Specifying Values In Language Files

Some of Laravel's built-in validation rule error messages contain a :value placeholder that is replaced with the current value of the request attribute. However, you may occasionally need the :value portion of your validation message to be replaced with a custom representation of the value. For example, consider the following rule that specifies that a credit card number is required if the payment_type has a value of cc:

    
    Validator::make($request->all(), [
        'credit_card_number' => 'required_if:payment_type,cc'
    ]);
	

If this validation rule fails, it will produce the following error message:

    
    The credit card number field is required when payment type is cc.
	

Instead of displaying cc as the payment type value, you may specify a more user-friendly value representation in your resources/lang/xx/validation.php language file by defining a values array:

    
    'values' => [
        'payment_type' => [
            'cc' => 'credit card'
        ],
    ],
	

After defining this value, the validation rule will produce the following error message:

    
    The credit card number field is required when payment type is credit card.