CompareWith<T extends Comparable<T>> class

A validator that compares a field's value with another form field's value.

CompareWith validates by comparing the current field's value against another field identified by a FormKey. Supports various comparison types including equality, greater than, less than, etc.

Example:

CompareWith.greaterOrEqual(
  FormKey<int>('minAge'),
  message: 'Must be at least the minimum age',
)
Inheritance

Constructors

CompareWith(FormKey<T> key, CompareType type, {String? message})
Creates a CompareWith validator with the specified comparison type.
const
CompareWith.equal(FormKey<T> key, {String? message})
Creates a validator that checks for equality with another field.
const
CompareWith.greater(FormKey<T> key, {String? message})
Creates a validator that checks if value is greater than another field.
const
CompareWith.greaterOrEqual(FormKey<T> key, {String? message})
Creates a validator that checks if value is greater than or equal to another field.
const
CompareWith.less(FormKey<T> key, {String? message})
Creates a validator that checks if value is less than another field.
const
CompareWith.lessOrEqual(FormKey<T> key, {String? message})
Creates a validator that checks if value is less than or equal to another field.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
key FormKey<T>
The form field key to compare against.
final
message String?
Custom error message, or null to use default localized message.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type CompareType
The type of comparison to perform.
final

Methods

combine(Validator<T> other) Validator<T>
Combines this validator with another validator using AND logic.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldRevalidate(FormKey source) bool
Determines if this validator should be re-run when the specified form key changes.
override
toString() String
A string representation of this object.
inherited
validate(BuildContext context, T? value, FormValidationMode state) FutureOr<ValidationResult?>
Validates the given value and returns a validation result.
override

Operators

operator &(Validator<T> other) Validator<T>
Combines this validator with another using AND logic (alias for combine).
inherited
operator +(Validator<T> other) Validator<T>
Combines this validator with another using AND logic (alias for combine).
inherited
operator ==(Object other) bool
The equality operator.
override
operator unary-() Validator<T>
Negates this validator's result (alias for ~ operator).
inherited
operator |(Validator<T> other) Validator<T>
Combines this validator with another using OR logic.
inherited
operator ~() Validator<T>
Negates this validator's result.
inherited