rules abstract method
Define the validation rules for this request.
This abstract method must be implemented by subclasses to specify the validation rules that should be applied to the request data.
Returns a Map where keys are field names and values are validation
rule strings. Multiple rules can be combined using the pipe | character.
Common validation rules include:
required- Field must be present and not emptyemail- Field must be a valid email addressmin:N- Field must be at least N characters/numbersmax:N- Field must not exceed N charactersstring- Field must be a stringnumeric- Field must be numeric
Example:
@override
Map<String, String> rules() {
return {
'name': 'required|string|max:255',
'email': 'required|email',
'age': 'required|numeric|min:18|max:120',
'password': 'required|min:8',
};
}
Returns: A map of field names to validation rule strings.
Implementation
Map<String, dynamic> rules();