-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
var inspector = require('../'); | ||
|
||
// var schema = { | ||
// type: 'object', | ||
// properties: { | ||
// lorem: { type: 'string', eq: 'ipsum' }, | ||
// dolor: { | ||
// type: 'array', | ||
// items: { type: 'number' } | ||
// } | ||
// } | ||
// }; | ||
var schema = { | ||
type: 'object', | ||
properties: { | ||
lorem: { type: 'string', eq: 'ipsum' }, | ||
dolor: { | ||
type: 'array', | ||
items: { type: 'number' } | ||
} | ||
} | ||
}; | ||
|
||
// var candidate = { | ||
// lorem: 'not_ipsum', | ||
// dolor: [ 12, 34, 'ERROR', 45, 'INVALID' ] | ||
// }; | ||
// var result = inspector.validate(schema, candidate, function (err, result) { | ||
// console.log(result.format()); | ||
// }); | ||
var candidate = { | ||
lorem: 'not_ipsum', | ||
dolor: [ 12, 34, 'ERROR', 45, 'INVALID' ] | ||
}; | ||
var result = inspector.validate(schema, candidate, function (err, result) { | ||
console.log(result); | ||
}); | ||
|
||
// var schema = { type: 'object', properties: { lol: { someKeys: ['pouet'] } } }; | ||
// var subject = { lol: null }; | ||
// inspector.validate(schema, subject); | ||
// inspector.validate(schema, subject); |
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,26 @@ | ||
if (typeof require === 'function') { | ||
var SchemaInspector = require('../'); | ||
} | ||
|
||
SchemaInspector.Validation.extend({ | ||
unique: function (schema, candidate, callback) { | ||
console.log(this.origin._connection); | ||
callback(); | ||
} | ||
}); | ||
|
||
var schema = { | ||
type: 'array', | ||
items: { | ||
type: 'number', $unique: true | ||
} | ||
}; | ||
|
||
var obj = [ 0, 5, 10, 15, 17, 20]; | ||
|
||
// ----------------------------------------------------------------------------- | ||
obj._connection = 'test'; | ||
SchemaInspector.validate(schema, obj, function (err, r) { | ||
console.log(r); | ||
console.log(r.format()); | ||
}); |
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