PostalCodePattern class abstract Extensibility
A pluggable postal-code validation strategy.
Implement this class to plug country-specific postal-code validation
into VString.postalCode. The core ships with UsZipPattern,
CaPostalCodePattern and UkPostcodePattern. External packages (e.g.
validart_br with CEP) can add more.
class BrCepPattern extends PostalCodePattern {
const BrCepPattern();
@override
String get name => 'CEP';
@override
bool matches(String value) =>
RegExp(r'^\d{5}-?\d{3}$').hasMatch(value);
}
V.string().postalCode(patterns: [const BrCepPattern()]);
See also:
- VString, which consumes patterns through its postal-code validator.
- UsZipPattern, CaPostalCodePattern and UkPostcodePattern, the built-in implementations.
- Implementers
Constructors
- PostalCodePattern()
-
Creates a PostalCodePattern.
const
Properties
Methods
-
matches(
String value) → bool -
Returns
trueifvaluematches this pattern's format. -
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