Skip to content

Commit 9e82908

Browse files
committed
Added outcode validation class method
1 parent 46dcf82 commit 9e82908

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ postcode.incode() // => "1QD"
2828
postcode.normalise() // => "ID1 1QD"
2929
```
3030

31+
Misc. Class Methods include
32+
33+
```
34+
Postcode.validOutcode(outcode)
35+
```
36+
37+
3138
## Testing
3239

3340
```npm test```

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Postcode (rawPostcode) {
2626
}
2727

2828
Postcode.validOutcode = function (outcode) {
29-
return !!outcode.match(validationRegex);
29+
return !!outcode.match(validOutcodeRegex);
3030
}
3131

3232
Postcode.prototype.valid = function () {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcode",
3-
"version": "0.1.3",
3+
"version": "0.2.0",
44
"description": "UK Postcode helper methods",
55
"main": "index.js",
66
"directories": {

tests/unit.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,13 @@ describe("Postcode.validOutcode", function () {
4646
testData = fs.readFile(path.join(dataDir, "outcodes.json"), function (error, data) {
4747
if (error) throw error;
4848
testData = JSON.parse(data);
49-
testData.forEach(function (test) {
49+
testData.tests.forEach(function (test) {
5050
assert.isTrue(Postcode.validOutcode(test.expected));
5151
});
5252
done();
5353
});
5454
});
55-
it ("should return false for invalid outcodes", function (done) {
56-
testData = fs.readFile(path.join(dataDir, "incodes.json"), function (error, data) {
57-
if (error) throw error;
58-
testData = JSON.parse(data);
59-
testData.forEach(function (test) {
60-
assert.isFalse(Postcode.validOutcode(test.expected));
61-
});
62-
done();
63-
});
64-
});
65-
})
55+
});
6656

6757
describe("Incode parsing", function () {
6858
before(function (done) {

0 commit comments

Comments
 (0)