matchField static method

String? matchField(
  1. String? value,
  2. dynamic otherFieldValue,
  3. String fieldName,
  4. String otherFieldName,
)

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;
}