Laravel Extended Validation custom message

后端 未结 4 1950
灰色年华
灰色年华 2021-01-04 10:03

I wanted to create this extended validation.

Validator::extend(\'my_custom_validation_rule\', function ($attribute, $value, $parameters) {
   // I guess I s         


        
4条回答
  •  一整个雨季
    2021-01-04 10:57

    You can also define the message for your custom validation rule under validation translations file.

    /resources/lang/en/validation.php

    ....
    'unique'                    => 'The :attribute has already been taken.',
    'uploaded'                  => 'The :attribute failed to upload.',
    'url'                       => 'The :attribute format is invalid.',
    //place your translation here
    'my_custom_validation_rule' => 'The :attribute value fails custom validation.'
    

提交回复
热议问题