isValidSpanishPostcodefunction
Whether a postcode follows Correos' shape: five digits, the first two a province's number (01 to 52). Whether it is in
use is a different question; isKnownSpanishPostcode asks it, and the validator checks both.
Import it
import { isValidSpanishPostcode } from "@johnmorrisdotca/address-plus/es";
Definition
function isValidSpanishPostcode(postcode: string): boolean
Parameters
| Name | Type | Description |
|---|---|---|
postcode | string | The postcode. |
Returns
boolean
true when it has the shape.
Examples
import { isValidSpanishPostcode } from "@johnmorrisdotca/address-plus/es";
console.log(["28014", "01001", "52080", "00100", "53000", "2801"].map(isValidSpanishPostcode));
// → [true,true,true,false,false,false][ true, true, true, false, false, false ]What it prints (run when this page was built)