Skip to content

Commit

Permalink
Add uuid as an alias for isUUID
Browse files Browse the repository at this point in the history
  • Loading branch information
nettofarah committed Feb 4, 2016
1 parent 3ec745c commit c1715ea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog


### 0.2.0(Feb 3, 2016)
- Add `uuid` as an alias for `isUUID`

### 0.1.2(Feb 3, 2016)
- Fix `matches` and `format` parameter order

Expand Down
10 changes: 5 additions & 5 deletions lib/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ validations.matches = validations.format = function matches(paramName, pattern)
return checkParam(paramName, 'should match ' + pattern.toString(), validator.matches, pattern);
}

// TODO: write more tests (from isDate to isUUID)
validations.isUUID = validations.uuid = function isUUID(paramName, version) {
return checkParam(paramName, 'should be an UUID', validator.isUUID, version);
}

// TODO: write more tests (from isDate to isURL)
validations.isDate = function isDate(paramName) {
return checkParam(paramName, 'should be a date', validator.isDate);
}
Expand Down Expand Up @@ -93,10 +97,6 @@ validations.isURL = function isURL(paramName, options) {
return checkParam(paramName, 'should be an URL', validator.isURL, options);
}

validations.isUUID = function isUUID(paramName, version) {
return checkParam(paramName, 'should be an UUID', validator.isUUID, version);
}

// TODO: Implement these validators
//
// isAfter(paramName [, date])
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "property-validator",
"version": "0.1.2",
"version": "0.2.0",
"description": "Easy property validation for JavaScript, Node and Express.",
"main": "index.js",
"homepage": "http://github.com/nettofarah/property-validator",
Expand Down
12 changes: 12 additions & 0 deletions test/validation_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,16 @@ describe('Validation Helpers', function() {
t(v.format('i', /\w+/)({ i: 'bla' }));
f(v.format('i', /\d+/)({ i: 'bla' }));
});

it('isUUID / uuid', function() {
t(v.isUUID('i')({ i: 'b7e34a19-1e65-4912-b43f-f68a93d4a1bd' }));
t(v.isUUID('i')({ i: 'A987FBC9-4BED-4078-8F07-9141BA07C9F3' }));
f(v.isUUID('i')({ i: 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3' }));
f(v.isUUID('i')({ i: 'bla' }));

t(v.uuid('i')({ i: 'b7e34a19-1e65-4912-b43f-f68a93d4a1bd' }));
t(v.uuid('i')({ i: 'A987FBC9-4BED-4078-8F07-9141BA07C9F3' }));
f(v.uuid('i')({ i: 'xxxA987FBC9-4BED-3078-CF07-9141BA07C9F3' }));
f(v.uuid('i')({ i: 'bla' }));
});
});

0 comments on commit c1715ea

Please sign in to comment.