rules abstract method

Map<String, dynamic> rules()

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 empty
  • email - Field must be a valid email address
  • min:N - Field must be at least N characters/numbers
  • max:N - Field must not exceed N characters
  • string - Field must be a string
  • numeric - 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();