RequiredIf<T> class

A validation rule that checks if a value is required conditionally based on either a condition or the equality of another field's value.

This rule validates that the input value is required if a specified condition is met or if the value of another field is equal to a specified value.

Inheritance

Constructors

RequiredIf(String? otherFieldName, {required dynamic equalTo, String? message})
Creates a new instance of the RequiredIf validation rule based on the equality of another field's value.
RequiredIf.condition(bool condition()?, {String? message})
Creates a new instance of the RequiredIf validation rule based on a condition.

Properties

condition → (bool Function()?)
The condition function that determines if the value is required.
final
equalTo → dynamic
The value to compare for equality against the other field's value.
final
hashCode int
The hash code for this object.
no setterinherited
l10n ValidatorLocalizations
The ValidatorLocalizations instance used for localization of validation messages. It's obtained through a service locator (sl) for convenience.
no setterinherited
otherFieldName String?
The name of the other field to compare equality against.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

message(String fieldName) String
Retrieves the validation message to be displayed.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
validate(T value, Map<String, FormFieldState> fields) bool
Validates the given value against the validation rule.
override
validatorMessage(String fieldName) String
Retrieves the validator message for the field.
override

Operators

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