[ { "name": "AA9A 9AA, the London EC1 form", "args": ["EC1A 1BB"], "expect": { "valid": true, "normalised": "EC1A 1BB", "outward": "EC1A", "inward": "1BB" } }, { "name": "A9A 9AA, the single-letter West End form", "args": ["W1A 0AX"], "expect": { "valid": true, "normalised": "W1A 0AX", "outward": "W1A", "inward": "0AX" } }, { "name": "A9 9AA, the shortest postcode there is", "args": ["M1 1AE"], "expect": { "valid": true, "normalised": "M1 1AE", "outward": "M1", "inward": "1AE" } }, { "name": "A99 9AA", "args": ["B33 8TH"], "expect": { "valid": true, "normalised": "B33 8TH", "outward": "B33", "inward": "8TH" } }, { "name": "AA9 9AA", "args": ["CR2 6XH"], "expect": { "valid": true, "normalised": "CR2 6XH", "outward": "CR2", "inward": "6XH" } }, { "name": "AA99 9AA, the longest postcode there is", "args": ["DN55 1PT"], "expect": { "valid": true, "normalised": "DN55 1PT", "outward": "DN55", "inward": "1PT" } }, { "name": "lower case and no space at all is normalised", "args": ["sw1a1aa"], "expect": { "valid": true, "normalised": "SW1A 1AA", "outward": "SW1A", "inward": "1AA" } }, { "name": "stray spaces anywhere are normalised away", "args": [" sw1a 1aa "], "expect": { "valid": true, "normalised": "SW1A 1AA", "outward": "SW1A", "inward": "1AA" } }, { "name": "the Girobank special case, which fits none of the six shapes", "args": ["GIR 0AA"], "expect": { "valid": true, "normalised": "GIR 0AA", "outward": "GIR", "inward": "0AA" } }, { "name": "the Girobank special case, unspaced and lower case", "args": ["gir0aa"], "expect": { "valid": true, "normalised": "GIR 0AA", "outward": "GIR", "inward": "0AA" } }, { "name": "a Scottish postcode, to pin the area rules beyond London", "args": ["EH12 9DN"], "expect": { "valid": true, "normalised": "EH12 9DN", "outward": "EH12", "inward": "9DN" } }, { "name": "a Northern Irish postcode", "args": ["BT1 5GS"], "expect": { "valid": true, "normalised": "BT1 5GS", "outward": "BT1", "inward": "5GS" } }, { "name": "the empty string is not a postcode", "args": [""], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "one character too long", "args": ["SW1A 1AAA"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "one character too short", "args": ["M1 1A"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "Q never starts a postcode area", "args": ["QW1A 1AA"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "I is never the second letter of an area", "args": ["SI1A 1AA"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "I is not one of the letters used in the AA9A fourth position", "args": ["SW1I 1AA"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "I is not one of the letters used in the A9A third position", "args": ["W1I 0AX"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "C is excluded from the first letter of the inward code", "args": ["SW1A 1CA"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "C is excluded from the second letter of the inward code", "args": ["SW1A 1AC"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "the inward code must end in two letters, not a digit", "args": ["SW1A 1A1"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "a postcode cannot start with a digit", "args": ["1W1A 1AA"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "all digits, the right length and still not a postcode", "args": ["12345"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "a hyphen is not a separator this accepts", "args": ["SW1A-1AA"], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } }, { "name": "a non-string argument is not a postcode", "args": [1], "expect": { "valid": false, "normalised": null, "outward": null, "inward": null } } ]