jeudi 1 novembre 2018

Laravel rule 'not' qualifier working but not firing validation message

As the title says, the validation rule is working, but no error message is triggered. I have tried putting an array of messages in the controller and passing it as the 3rd argument to the validator, but this resulted in none of the other validation messages displaying either. The validator is failing when an url is entered, but the user is not given any feedback. I would rather avoid writing a custom validation rule, as laravel already has the functionality for checking urls and negating rules.

I have read through the following answers, and also the laravel website.

Laravel validator::make vs this->validate()

Custom message laravel Validation

Laravel Validation Rule array not working

https://laravel.com/docs/5.7/validation

MyController.php :

protected $rules = [
    'title' => 'filled|max:80|!url',
];

resources/lang/en/validation.php :

'custom' => [
    'attribute-name' => [
        'rule-name' => 'custom-message',
    ],
    'title' => [
        '!url' => 'The :attribute cannot be an URL.',
    ],
],

Any and all help is welcomed and appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire