MaxLengthValidator class

Ensures the value contains no more than max Unicode code points (runes).

The value is trimmed before counting, so surrounding whitespace neither counts toward nor pads the length. Note that a code point is not always a user-perceived character: a multi-code-point grapheme cluster (e.g. a ZWJ emoji) counts as more than one.

Inheritance

Constructors

MaxLengthValidator({required int max, required String error, bool ignoreEmptyValues = true})
const

Properties

error String
The error message returned when validation fails.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
ignoreEmptyValues bool
Whether empty input (see isEmpty) short-circuits to "valid".
finalinherited
max int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(String? value) String?
Validates value: returns null when it is acceptable, error when it is not.
inherited
isEmpty(String value) bool
Treats whitespace-only input as blank so an optional field never reports a format error when "left blank". Trimming only gates the skip; the raw value is still what isValid receives.
inherited
isValid(String value) bool
Checks whether a non-empty value satisfies the validation criteria.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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