Skip to content

Commit c1715ea

Browse files
committed
Add uuid as an alias for isUUID
1 parent 3ec745c commit c1715ea

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
4+
### 0.2.0(Feb 3, 2016)
5+
- Add `uuid` as an alias for `isUUID`
6+
37
### 0.1.2(Feb 3, 2016)
48
- Fix `matches` and `format` parameter order
59

lib/validations.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ validations.matches = validations.format = function matches(paramName, pattern)
6060
return checkParam(paramName, 'should match ' + pattern.toString(), validator.matches, pattern);
6161
}
6262

63-
// TODO: write more tests (from isDate to isUUID)
63+
validations.isUUID = validations.uuid = function isUUID(paramName, version) {
64+
return checkParam(paramName, 'should be an UUID', validator.isUUID, version);
65+
}
66+
67+
// TODO: write more tests (from isDate to isURL)
6468
validations.isDate = function isDate(paramName) {
6569
return checkParam(paramName, 'should be a date', validator.isDate);
6670
}
@@ -93,10 +97,6 @@ validations.isURL = function isURL(paramName, options) {
9397
return checkParam(paramName, 'should be an URL', validator.isURL, options);
9498
}
9599

96-
validations.isUUID = function isUUID(paramName, version) {
97-
return checkParam(paramName, 'should be an UUID', validator.isUUID, version);
98-
}
99-
100100
// TODO: Implement these validators
101101
//
102102
// isAfter(paramName [, date])

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "property-validator",
3-
"version": "0.1.2",
3+
"version": "0.2.0",
44
"description": "Easy property validation for JavaScript, Node and Express.",
55
"main": "index.js",
66
"homepage": "http://github.com/nettofarah/property-validator",

test/validation_test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,16 @@ describe('Validation Helpers', function() {
125125
t(v.format('i', /\w+/)({ i: 'bla' }));
126126
f(v.format('i', /\d+/)({ i: 'bla' }));
127127
});
128+
129+
it('isUUID / uuid', function() {
130+
t(v.isUUID('i')({ i: 'b7e34a19-1e65-4912-b43f-f68a93d4a1bd' }));
131+
t(v.isUUID('i')({ i: 'A987FBC9-4BED-4078-8F07-9141BA07C9F3' }));
132+
f(v.isUUID('i')({ i: 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3' }));
133+
f(v.isUUID('i')({ i: 'bla' }));
134+
135+
t(v.uuid('i')({ i: 'b7e34a19-1e65-4912-b43f-f68a93d4a1bd' }));
136+
t(v.uuid('i')({ i: 'A987FBC9-4BED-4078-8F07-9141BA07C9F3' }));
137+
f(v.uuid('i')({ i: 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3' }));
138+
f(v.uuid('i')({ i: 'bla' }));
139+
});
128140
});

0 commit comments

Comments
 (0)