ValidationMode enum Core
Controls which formatted variants a pattern accepts.
Many string validators accept the same information in more than one
shape — 123-45-6789 vs 123456789, K1A 0B1 vs K1A0B1. The mode
lets callers pin the input to a specific shape instead of silently
accepting both.
Defaults to any on every pattern that supports the mode, which keeps current behavior. Pass formatted to require the separators to be present; pass unformatted to require them to be absent.
V.string().postalCode(
patterns: [const UkPostcodePattern(mode: ValidationMode.formatted)],
);
V.string().taxId(
patterns: [const UsSsnPattern(mode: ValidationMode.unformatted)],
);
See also:
Values
- any → const ValidationMode
-
Accept the input with or without formatting separators.
The same value in either shape is valid — e.g.
123-45-6789and123456789are both accepted by UsSsnPattern when the mode isany. - formatted → const ValidationMode
-
Only accept the input in its fully-formatted form.
Rejects inputs missing the expected separators.
- unformatted → const ValidationMode
-
Only accept the input stripped of formatting separators.
Rejects inputs that contain any separator character the pattern would otherwise treat as formatting.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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
Constants
-
values
→ const List<
ValidationMode> - A constant List of the values in this enum, in order of their declaration.