-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Suggestion for improvement
After extensive testing of the library against a list of addresses (some invalid, some valid) I have found it would be very useful if it would accept post codes without dashes. For example the format for Brazil is #####-### but often people skip the dash, making it an invalid code. Currently I have implemented this with a wrapper class that uses the ignoreSpaces parameter and replaces - with -? in the expression.
protected function getFormatPattern(string $format, bool $ignoreSpacesAndDashes = false): string {
if ($ignoreSpacesAndDashes) {
$format = str_replace('-', '-?', $format);
}
$pattern = parent::getFormatPattern($format, $ignoreSpacesAndDashes);
error_log($pattern);
return $pattern;
}
That being said I think it would be better if that was baked in the library itself.
(Updated code to fix a pattern bug)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels