One method of registering custom validation rules is using rule objects.
First, let's assume we have the following routes defined in our object.
If the validation rules pass, your code will keep executing normally; however, if validation fails, an exception will be thrown and the proper error response will automatically be sent back to the user.
To quickly accomplish this, add the Sometimes you may wish to add validation rules based on more complex conditional logic.
For example, you may wish to require a given field only if another field has a greater value than 100.
The above example code is also available in Bcrypt-SHA-384 flavor. When we say "don't encrypt passwords", we're talking about server-side password validation.