-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #176: Add UUID validation type
A data type represented by strings that are formatted as universally unique identifiers.
- Loading branch information
1 parent
e41cce4
commit 969a1c0
Showing
9 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
myDocType: { | ||
typeFilter: simpleTypeFilter, | ||
channels: { write: 'write' }, | ||
propertyValidators: { | ||
uuidProp: { | ||
type: 'uuid' | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
var testHelper = require('../src/test-helper.js'); | ||
var errorFormatter = testHelper.validationErrorFormatter; | ||
|
||
describe('UUID validation type', function() { | ||
beforeEach(function() { | ||
testHelper.initSyncFunction('build/sync-functions/test-uuid-sync-function.js'); | ||
}); | ||
|
||
it('allows a valid UUID with lowercase letters', function() { | ||
var doc = { | ||
_id: 'my-doc', | ||
type: 'myDocType', | ||
uuidProp: '1511fba4-e039-42cc-9ac2-9f2fa29eecfc' | ||
}; | ||
|
||
testHelper.verifyDocumentCreated(doc); | ||
}); | ||
|
||
it('allows a valid UUID with uppercase letters', function() { | ||
var doc = { | ||
_id: 'my-doc', | ||
type: 'myDocType', | ||
uuidProp: 'DFF421EA-0AB2-45C9-989C-12C76E7282B8' | ||
}; | ||
|
||
testHelper.verifyDocumentCreated(doc); | ||
}); | ||
|
||
it('rejects a UUID with invalid characters', function() { | ||
var doc = { | ||
_id: 'my-doc', | ||
type: 'myDocType', | ||
uuidProp: 'g78d516e-cb95-4ef7-b593-2ee7ce375738' | ||
}; | ||
|
||
testHelper.verifyDocumentNotCreated(doc, 'myDocType', [ errorFormatter.uuidFormatInvalid('uuidProp') ]); | ||
}); | ||
|
||
it('rejects a UUID without hyphens', function() { | ||
var doc = { | ||
_id: 'my-doc', | ||
type: 'myDocType', | ||
uuidProp: '1511fba4e03942cc9ac29f2fa29eecfc' | ||
}; | ||
|
||
testHelper.verifyDocumentNotCreated(doc, 'myDocType', [ errorFormatter.uuidFormatInvalid('uuidProp') ]); | ||
}); | ||
|
||
it('rejects a UUID with too many characters', function() { | ||
var doc = { | ||
_id: 'my-doc', | ||
type: 'myDocType', | ||
uuidProp: '1511fba4-e039-42cc-9ac2-9f2fa29eecfc3' | ||
}; | ||
|
||
testHelper.verifyDocumentNotCreated(doc, 'myDocType', [ errorFormatter.uuidFormatInvalid('uuidProp') ]); | ||
}); | ||
|
||
it('rejects a UUID with too few characters', function() { | ||
var doc = { | ||
_id: 'my-doc', | ||
type: 'myDocType', | ||
uuidProp: '1511fba4-e03-42cc-9ac2-9f2fa29eecfc' | ||
}; | ||
|
||
testHelper.verifyDocumentNotCreated(doc, 'myDocType', [ errorFormatter.uuidFormatInvalid('uuidProp') ]); | ||
}); | ||
}); |