You are here

public function PostalCodeValidation::getValidationPatterns in Postal Code 8

Actual validation function.

Return value

array of RegExp patterns for validation.

Overrides PostalCodeValidationInterface::getValidationPatterns

1 call to PostalCodeValidation::getValidationPatterns()
PostalCodeValidation::validate in src/PostalCodeValidation.php
Custom function defining regexes corresponding to different countries.

File

src/PostalCodeValidation.php, line 19

Class

PostalCodeValidation
Provide additional methods for validations of postal code field.

Namespace

Drupal\postal_code

Code

public function getValidationPatterns() {

  // Populate the country list if it is not already populated.
  if (!isset($this->countries)) {
    $this->countries = static::getAllowedValidationPatterns();
  }
  return $this->countries;
}