LicensePlatePattern class abstract Extensibility

A pluggable license-plate validation strategy.

The core ships with UkPlatePattern (post-2001 format, which is stable nationwide). Plates from countries with heavy regional variation — US (per-state) and Canada (per-province) — are intentionally not built in; implement them per your use case or use extension packages.

V.string().licensePlate(patterns: [const UkPlatePattern()]);

class BrMercosulPattern extends LicensePlatePattern {
  const BrMercosulPattern();
  @override
  String get name => 'BR Mercosul';
  @override
  bool matches(String value) =>
      RegExp(r'^[A-Z]{3}\d[A-Z]\d{2}$').hasMatch(value);
}

See also:

  • VString, which consumes patterns through its license-plate validator.
  • UkPlatePattern, the only built-in implementation.
Implementers

Constructors

LicensePlatePattern()
Creates a LicensePlatePattern.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
name String
Human-readable name used in error messages and debugging.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

matches(String value) bool
Returns true if value is a valid license plate for this pattern.
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