another-json-schema
Advanced tools
Comparing version 3.5.0 to 3.5.1
@@ -0,1 +1,5 @@ | ||
## 3.5.1/2018-04-12 | ||
- add `.eq` `.equal` validator | ||
## 3.5.0/2018-04-11 | ||
@@ -2,0 +6,0 @@ |
@@ -57,1 +57,9 @@ const toString = Object.prototype.toString | ||
} | ||
/* | ||
* common | ||
*/ | ||
exports.eq = exports.equal = function (actual, expected, key, parent) { | ||
return actual === expected | ||
} |
{ | ||
"name": "another-json-schema", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"description": "Another JSON Schema, simple & flexible & intuitive.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -358,2 +358,3 @@ ### another-json-schema | ||
- type | ||
- eq|equal | ||
- gt | ||
@@ -360,0 +361,0 @@ - gte |
@@ -135,2 +135,18 @@ const AJS = require('..') | ||
it('.eq, .equal', function () { | ||
const numberSchema = AJS('numberSchema', { type: 'number', eq: 0 }) | ||
assert.deepEqual(numberSchema.validate(0), { valid: true, error: null, result: 0 }) | ||
const stringSchema = AJS('stringSchema', { type: 'string', equal: 'haha' }) | ||
assert.deepEqual(stringSchema.validate('hehe'), { valid: false, | ||
error: | ||
{ | ||
validator: 'equal', | ||
path: '$', | ||
actual: 'hehe', | ||
expected: { type: 'string', equal: 'haha' }, | ||
schema: 'stringSchema' }, | ||
result: 'hehe' }) | ||
}) | ||
it('.gt', function () { | ||
@@ -137,0 +153,0 @@ const schema = AJS('numberSchema', { type: 'number', gt: 0 }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46486
1181
393