Reputation: 14978
I want to show my own message instead of one provided by the framework, So I did the following but it is not making any difference and showing default messages.
$message = [];
foreach($request->get('estimates') as $key => $val)
{
$rules['estimates.'.$key] = 'required|integer';
$message['estimates.'.$key] = 'Incorrect value';
}
$rules['technical_information'] = 'required';
$rules['project_risks'] = 'required';
$this->validate($request, $rules,$message);
Upvotes: 0
Views: 1351
Reputation: 7535
I believe you need to adhere to the correct format for messages. Per the Laravel docs:
$messages = [
'required' => 'The :attribute field is required.',
];
$validator = Validator::make($input, $rules, $messages);
The key in $messages
needs to be the rule , and the value is the Message -- with a placeholder for the attribute name.
You can also specify messages per rule, per attribute by using dot syntax:
'username.required' => 'the field is required...'
Upvotes: 3