summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/index.js')
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/index.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/index.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/index.js
index f929bb7539..779cfe20bf 100644
--- a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/index.js
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/index.js
@@ -514,15 +514,23 @@ var compile = function(schema, cache, root, reporter, opts) {
}
if (node.minimum !== undefined) {
+ if (type !== 'number' && type !== 'integer') validate('if (%s) {', types.number(name))
+
validate('if (%s %s %d) {', name, node.exclusiveMinimum ? '<=' : '<', node.minimum)
error('is less than minimum')
validate('}')
+
+ if (type !== 'number' && type !== 'integer') validate('}')
}
if (node.maximum !== undefined) {
+ if (type !== 'number' && type !== 'integer') validate('if (%s) {', types.number(name))
+
validate('if (%s %s %d) {', name, node.exclusiveMaximum ? '>=' : '>', node.maximum)
error('is more than maximum')
validate('}')
+
+ if (type !== 'number' && type !== 'integer') validate('}')
}
if (properties) {
@@ -540,6 +548,8 @@ var compile = function(schema, cache, root, reporter, opts) {
var validate = genfun
('function validate(data) {')
+ // Since undefined is not a valid JSON value, we coerce to null and other checks will catch this
+ ('if (data === undefined) data = null')
('validate.errors = null')
('var errors = 0')