You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In places where a "number" is required, a "string" value is accepted. Moreover, numeric constraints like "minimum" are correctly applied to numeric values, but are ignored for string values. Here's a test program:
/* * test case for json-schema validation issue with strings as integers */varassert=require('assert');varjsonschema=require('json-schema');varschema={'type': 'integer','minimum': 0};console.log('validate -1 as a positive integer (expect fail, got fail)');console.log(jsonschema.validate(-1,schema));console.log('validate 1 as a positive integer (expect okay, got okay)');console.log(jsonschema.validate(1,schema));console.log('FAIL: validate "-1" as a positive integer (expect fail, got okay)');console.log(jsonschema.validate('-1',schema));console.log('FAIL: validate "1" as a positive integer (expect fail, got okay)');console.log(jsonschema.validate('1',schema));
and here's the output for my system:
dap@sharptooth jst $ uname -a
Darwin sharptooth.local 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
dap@sharptooth jst $ node -v
v0.10.18
dap@sharptooth jst $ npm ls
/Users/dap/Desktop/jst
└── [email protected]
dap@sharptooth jst $ node issue-int.js
validate -1 as a positive integer (expect fail, got fail)
{ valid: false,
errors: [ { property: '', message: 'must have a minimum value of 0' } ] }
validate 1 as a positive integer (expect okay, got okay)
{ valid: true, errors: [] }
FAIL: validate "-1" as a positive integer (expect fail, got okay)
{ valid: true, errors: [] }
FAIL: validate "1" as a positive integer (expect fail, got okay)
{ valid: true, errors: [] }
The text was updated successfully, but these errors were encountered:
In places where a "number" is required, a "string" value is accepted. Moreover, numeric constraints like "minimum" are correctly applied to numeric values, but are ignored for string values. Here's a test program:
and here's the output for my system:
The text was updated successfully, but these errors were encountered: