Chromium Code Reviews| Index: chrome/renderer/resources/json_schema.js |
| =================================================================== |
| --- chrome/renderer/resources/json_schema.js (revision 65777) |
| +++ chrome/renderer/resources/json_schema.js (working copy) |
| @@ -105,7 +105,7 @@ |
| */ |
| chromeHidden.JSONSchemaValidator.getType = function(value) { |
| var s = typeof value; |
| - |
| + var maxInt = -1 >>> 1; |
|
Aaron Boodman
2010/11/18 23:04:35
This is not the largest representable integer in J
|
| if (s == "object") { |
| if (value === null) { |
| return "null"; |
| @@ -114,7 +114,7 @@ |
| return "array"; |
| } |
| } else if (s == "number") { |
| - if (value % 1 == 0) { |
| + if ((value % 1 == 0) && (Math.abs(value) <= maxInt)) { |
| return "integer"; |
| } |
| } |
| @@ -380,10 +380,10 @@ |
| */ |
| chromeHidden.JSONSchemaValidator.prototype.validateString = function( |
| instance, schema, path) { |
| - if (schema.minLength && instance.length < schema.minLength) |
| + if ('minLength' in schema && instance.length < schema.minLength) |
| this.addError(path, "stringMinLength", [schema.minLength]); |
| - if (schema.maxLength && instance.length > schema.maxLength) |
| + if ('maxLength' in schema && instance.length > schema.maxLength) |
| this.addError(path, "stringMaxLength", [schema.maxLength]); |
| if (schema.pattern && !schema.pattern.test(instance)) |
| @@ -405,10 +405,10 @@ |
| instance == Number.NEGATIVE_INFINITY ) |
| this.addError(path, "numberFiniteNotNan", [instance]); |
| - if (schema.minimum && instance < schema.minimum) |
| + if ('minimum' in schema && instance < schema.minimum) |
| this.addError(path, "numberMinValue", [schema.minimum]); |
| - if (schema.maximum && instance > schema.maximum) |
| + if ('maximum' in schema && instance > schema.maximum) |
| this.addError(path, "numberMaxValue", [schema.maximum]); |
| if (schema.maxDecimal && instance * Math.pow(10, schema.maxDecimal) % 1) |