RefineMapValidator class

A specialized validator for refining validation logic on a map.

This validator allows custom validation rules for a map structure and enables error messages to be associated with a specific key path.

Example

final validator = v.map({
  'email': v.string().email(),
  'password': v.string().min(8),
  'confirmPassword': v.string().min(8),
}).refine(
  (data) => data?['password'] == data?['confirmPassword'],
  path: 'confirmPassword',
  message: 'Passwords do not match',
);

print(validator.validate({
  'email': 'test@example.com',
  'password': 'secret123',
  'confirmPassword': 'secret123',
})); // true

print(validator.validate({
  'email': 'test@example.com',
  'password': 'secret123',
  'confirmPassword': 'wrongpass',
})); // false, because passwords do not match
Inheritance

Constructors

RefineMapValidator.new(bool validator(Map<String, dynamic> data), {required String message, required String path})
Creates a RefineMapValidator with a custom validation function.

Properties

hashCode int
The hash code for this object.
no setterinherited
message String
The error message to be returned when validation fails.
finalinherited
path String
The key path where the validation error should be reported.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
validator bool Function(Map<String, dynamic> data)
A custom function that determines whether the value is valid.
finalinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
validate(covariant Map<String, dynamic> value) String?
Validates the provided value.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited