matchField static method
Validates that a field matches another field (e.g., password confirmation).
value - Current field value
otherFieldValue - Value of the field to match against
fieldName - Name of current field for error message
otherFieldName - Name of other field for error message
Implementation
static String? matchField(
String? value,
dynamic otherFieldValue,
String fieldName,
String otherFieldName,
) {
if (value == null || value.isEmpty) {
return null; // Don't validate empty values
}
if (value != otherFieldValue?.toString()) {
return '$fieldName must match $otherFieldName.';
}
return null;
}