joi-objectid
Advanced tools
Comparing version 1.0.0 to 1.1.0
1.1.0 / 2014-12-10 | ||
================== | ||
* Check based on a regexp matching only hexadecimal #1 [https://github.com/Marsup](Marsup) | ||
1.0.0 / 2014-09-19 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -5,3 +5,3 @@ | ||
module.exports = function objectId() { | ||
return Joi.string().alphanum().length(24); | ||
} | ||
return Joi.string().regex(/^[0-9a-fA-F]{24}$/); | ||
}; |
{ | ||
"name": "joi-objectid", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A MongoDB ObjectId validator for Joi", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
12
test.js
@@ -7,8 +7,8 @@ | ||
describe('joi-objectid', function() { | ||
it('requires an alphnum string of 24 chars', function(done) { | ||
it('requires an hexadecimal string of 24 chars', function(done) { | ||
var tests = [ | ||
{ val: '$sdf56789012345678901234', pass: false } | ||
, { val: ' sdf56789012345678901234', pass: false } | ||
, { val: 'asdf5678901234567890123', pass: false } | ||
, { val: 'asdf56789012345678901234', pass: true } | ||
{ val: '$bcd56789012345678901234', pass: false } | ||
, { val: ' bcd56789012345678901234', pass: false } | ||
, { val: 'abcd5678901234567890123', pass: false } | ||
, { val: 'abcd56789012345678901234', pass: true } | ||
, { val: 123456789012345678901234, pass: false } | ||
@@ -23,3 +23,3 @@ , { val: { length: 24 } , pass: false } | ||
assert(test.pass === ! res.error, res.error); | ||
}) | ||
}); | ||
@@ -26,0 +26,0 @@ done(); |
3421