isValidIndianPostcodefunction
Whether a PIN code follows India Post's shape: six digits, the first not nought, with or without a space after the third.
Whether it is in use is a different question; isKnownIndianPostcode asks it, and the validator checks both.
Import it
import { isValidIndianPostcode } from "@johnmorrisdotca/address-plus/in";
Definition
function isValidIndianPostcode(postcode: string): boolean
Parameters
| Name | Type | Description |
|---|---|---|
postcode | string | The PIN code. |
Returns
boolean
true when it has the shape.
Examples
import { isValidIndianPostcode } from "@johnmorrisdotca/address-plus/in";
console.log(["560038", "560 038", "060038", "56003", "5600381"].map(isValidIndianPostcode));
// → [true,true,false,false,false][ true, true, false, false, false ]What it prints (run when this page was built)