EDDYMENS

Published 9 months ago

How To Check If A User's Input Is One Of The Permitted Options During Validation | Laravel 10

In validating a user input against a list of options you will need to use the in validation keyword.

Here is an example:

01: $validator = Validator::make($request->all(), [ 02: 'email' => 'required|email', 03: 'password' => 'required', 04: 'account-type' => 'in:publisher,subscriber' 05: ], $this->messages);

In the above example account-type the user's account type input will be validated using 'in:publisher,subscriber' rule. The Laravel error bag is filled whenever the input does not correspond to either publisher or subscriber.

Here is another article you might like 😊 How To Change The Width And Height Of Feathericons.com Icons