PostalCode class final

A class that represents a postal code format and regular expression pattern.

The PostalCode class is a simple value object that represents a postal code format and regular expression pattern. It consists of two string values - a format string that describes the format of a postal code (e.g. "#####"), and a regExpPattern string that specifies a regular expression pattern that can be used to validate postal codes.

Example usage:

final postalCode =
  PostalCode(format: '#####-####', regExpPattern: r'^(\d{5}(-\d{4})?)$');
print(postalCode.format); // Prints: '#####-####'
print(postalCode.regExpPattern); // Prints: '^(\\d{5}(-\\d{4})?)$'
Implemented types
Available extensions

Constructors

PostalCode({String format = "#####", String regExpPattern = r"^(\d{5})$"})
Creates a new PostalCode object with the given format and regular expression pattern.
const

Properties

format → String
The format string for this PostalCode object.
final
hashCode → int
The hash code for this object.
no setteroverride
regExpPattern → String
The regular expression pattern for this PostalCode object.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({String? format, String? regExpPattern}) → PostalCode

Available on PostalCode, provided by the PostalCodeExtension extension

Creates a copy of this object with the given fields replaced with the new values.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson({JsonCodec codec = const JsonCodec()}) → String
Returns a JSON-encoded string representation of the object.
override
toMap() → Map<String, String>

Available on PostalCode, provided by the PostalCodeExtension extension

Converts this object object to a JSON like map.
toString() → String
A string representation of this object.
override
validator({bool caseSensitive = true, bool dotAll = false, bool multiLine = false, bool unicode = false}) → RegExp

Available on PostalCode, provided by the PostalCodeExtension extension

Returns a RegExp object that can be used to validate postal codes.

Operators

operator ==(covariant PostalCode other) → bool
The equality operator.
override