To use the custom validator, first, we have to load it in our controller by writing use Validator.
After that, we have to use make method of validator in which we pass all the parameters of the request object, in the second parameter we pass our validation rules and, in the third parameter we pass our custom messages.
If any error found in the object or parameter then, fails() catch it and redirects to the same page with all errors else print the given output. See below:-
See the code below:–
Output
See when we provide invalid email then our customised message appears or not:-
Output
Now See the output whether it returns a message when we did not provide value in the given field.
Now, When we fill 1-2 field and left other then what message returns. See below:-
When we fill all the fields, then what returns:-
- What is On-Page Optimization and Off-page Optimization - March 14, 2024
- [SOLVED] Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) - December 7, 2021
- [Solved] Flutter : Error: The getter ‘subhead’ isn’t defined for the class ‘TextTheme’ from package:flutter/src/material/text_theme.dart’ – searchable_dropdown - December 6, 2021