Skip to main content
Version: 1.2.0

isPostalCode

Using this method, you can check whether the received input is a postal code or not

Params

isPostalCode(postalCode,regions = []);
  • postalCode → postalCode Write the string you want to check whether it is a postalCode or not in this parameter and pass it to the function
  • regions → An array of regions where the postal code must be in the form of one of these regions to return true, if this parameter is not given, all possible regions will be checked by default.
regions

The text format of the region string is exactly the same as the express-validator package

Returns

true | false
  • Boolean → If the input string is a PostalCode, it returns true and if the input string is not a PostalCode, it returns false.

Usage


isPostalCode("12345-12345",['fa-IR']); //true

isPostalCode("12345-12345",['en-US']); //false

isPostalCode("12345-12345",['en-US','fa-IR']); //true