Laravel custom validation

Posted 11 months ago by codemode

In my controller i'm doing some validation like :

 $this->validate(request(),  
            [ 'add_button' => 'required|integer|notIn:'.$requested_by ], 
            [ 'notIn' => 'This value has to be different' ]);

...this is in reference to the following format : $this->validate($request, $rules, $customMessages);

So, i'm using the "notIn" validator to check that the "add_button" value is not equal to "$requested_by"

Though the validation works, but the custom message is not not displayed. On the contrary, if i put a custom validation message for "required" or something like "max" - then the custom validation message is displayed just fine.

Where am i going wrong?

Thanks.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.