We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e94aba0 + b09c022 commit 9e212a0Copy full SHA for 9e212a0
2 files changed
index.js
@@ -1,11 +1,11 @@
1
"use strict";
2
3
-var validationRegex = /^[a-z0-9]{1,4}\s*?\d[a-z]{2}$/i,
+var validationRegex = /^[a-z][a-z\d]{1,3}\s*?\d[a-z]{2}$/i,
4
incodeRegex = /\d[a-z]{2}$/i,
5
- validOutcodeRegex = /^[a-z0-9]{1,4}$/i,
+ validOutcodeRegex = /^[a-z][a-z\d]{1,3}$/i,
6
areaRegex = /^[a-z]{1,2}/i,
7
districtSplitRegex = /^([a-z]{1,2}\d)([a-z])$/i,
8
- sectorRegex = /^[a-z0-9]{1,4}\s*?\d/i,
+ sectorRegex = /^[a-z][a-z\d]{1,3}\s*?\d/i,
9
unitRegex = /[a-z]{2}$/i;
10
11
function isValidPostcode (postcode) {
tests/data/validation.json
@@ -28,6 +28,14 @@
28
"base" : "12FSSD",
29
"expected" : false
30
},
31
+ {
32
+ "base" : "1A1 1AA",
33
+ "expected" : false
34
+ },
35
36
+ "base" : "MA1 1AA",
37
+ "expected" : true
38
39
{
40
"base" : "BT35 8GE",
41
"expected" : true
0 commit comments