Does the validation class in Laravel validate exact words?
eg
$rules = [ "field" => "hello" ]
Where the value of the field must be "hello".
Yes. I know of at least two ways.
// option one: 'in' takes a comma-separated list of acceptable values $rules = [ 'field' => 'in:hello', ]; // option two: write a matching regular expression $rules = [ 'field' => 'regex:^hello$', ];
Actually, I don't remember if you need the ^$ delimiters in the regex, but it's easy to find out by trying it. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With