how to pass custom validation message to cviebrock

2019-07-20 12:59发布

问题:

I am using cviebrock for validating image size in laravel. And thats working fine. But I want to customize the error message.

I created an array of message

 $messages = array(
        'image-size'    => 'My custome message.',
    );

and passed to

$validation = Validator::make(array($file => $fileObj), array($file  => $rules), $messages);

But thats not working.

-Thanks Arun

回答1:

You're using the wrong name, it should be with an underline, like

$messages = array(
    'image_size'    => 'My custome message.',
);