validate method
Validates the given value against the validation rule.
value: The value to be validated.fields: A map of form field states for cross-field validation.
Returns true if the validation passes, false otherwise.
Implementation
@override
bool validate(T value, Map<String, FormFieldState> fields) {
var requiredConditionFulfilled = false;
if (condition != null) {
requiredConditionFulfilled = condition!();
} else if (fields[otherFieldName!]?.value == equalTo) {
requiredConditionFulfilled = true;
}
if (requiredConditionFulfilled) {
if (value is String) {
return value.isNotEmpty;
} else if (value is Iterable) {
return value.isNotEmpty;
} else {
return value != null;
}
}
return requiredConditionFulfilled;
}