0

How can I change the value used in the error feedback, lets say I have this rule:

$rules = array(
    'valid_country_code'                   => 'required',
);

But instead of 'valid_country_code' I want the user to see 'country' in the error message. The message at the moment.

valid_country_code is required.

what I want

country is required.

But I dont want to change the name in the form when posting because I want to bind the form to a model.

Sven van den Boogaart
  • 11,833
  • 21
  • 86
  • 169
  • 1
    it has all been said in various questions on stack overflow... for example: http://stackoverflow.com/questions/17047116/laravel-validation-attributes-nice-names – shock_gone_wild Dec 28 '15 at 14:56

1 Answers1

0

You may pass the custom messages as the third argument to the Validator::make method:

$rules = array(
    'valid_country_code' => 'required',
);

$messages = [
    'valid_country_code.required' => 'country is required.',
];

$validator = Validator::make($input, $rules, $messages);
Peter Kota
  • 8,048
  • 5
  • 25
  • 51