DevonDahon
DevonDahon

Reputation: 8350

Laravel Validation : Match one of two values

I have a title attribute in my list of field to validate, instead of checking if it's a string, how can I check that it's equal either to M or MME?

$attributes = [
  'title' => ['string']
];

$validator = Validator::make($request->user, $attributes);

Upvotes: 0

Views: 999

Answers (1)

James Clark
James Clark

Reputation: 1325

You can use the 'in' validation rule.

'title' => ['in:M,MME'],

https://laravel.com/docs/master/validation#rule-in

Upvotes: 3

Related Questions