CompareTo<T extends Comparable<T>> class

A validator that compares a value against a static comparison value.

CompareTo validates by comparing the field value against a fixed value (unlike CompareWith which compares against another field). Supports various comparison types.

Example:

CompareTo.greaterOrEqual(
  18,
  message: 'Must be at least 18',
)
Inheritance

Constructors

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

Properties

hashCode int
The hash code for this object.
no setteroverride
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
value → T?
The value to compare against.
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.
inherited
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