LengthValidator class
A validator that checks if a string's length is within specified bounds.
LengthValidator validates that a string's length falls within the minimum and/or maximum bounds. Either bound can be null to check only one direction.
Example:
LengthValidator(
min: 3,
max: 20,
message: 'Must be between 3 and 20 characters',
)
Constructors
- LengthValidator({int? min, int? max, String? message})
-
Creates a LengthValidator with optional min/max bounds.
const
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- max → int?
-
Maximum length requirement (inclusive), or null for no maximum.
final
- message → String?
-
Custom error message, or null to use default localized message.
final
- min → int?
-
Minimum length requirement (inclusive), or null for no minimum.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
combine(
Validator< String> other) → Validator<String> -
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, String? value, FormValidationMode state) → FutureOr< ValidationResult?> -
Validates the given
valueand returns a validation result.override
Operators
-
operator &(
Validator< String> other) → Validator<String> -
Combines this validator with another using AND logic (alias for combine).
inherited
-
operator +(
Validator< String> other) → Validator<String> -
Combines this validator with another using AND logic (alias for combine).
inherited
-
operator ==(
Object other) → bool -
The equality operator.
override
-
operator unary-(
) → Validator< String> -
Negates this validator's result (alias for
~operator).inherited -
operator |(
Validator< String> other) → Validator<String> -
Combines this validator with another using OR logic.
inherited
-
operator ~(
) → Validator< String> -
Negates this validator's result.
inherited