| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ----------------------------------------------------------------------------- | 5 // ----------------------------------------------------------------------------- |
| 6 // NOTE: If you change this file you need to touch renderer_resources.grd to | 6 // NOTE: If you change this file you need to touch renderer_resources.grd to |
| 7 // have your change take effect. | 7 // have your change take effect. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 | 9 |
| 10 //============================================================================== | 10 //============================================================================== |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 instance, schema, path) { | 398 instance, schema, path) { |
| 399 | 399 |
| 400 // Forbid NaN, +Infinity, and -Infinity. Our APIs don't use them, and | 400 // Forbid NaN, +Infinity, and -Infinity. Our APIs don't use them, and |
| 401 // JSON serialization encodes them as 'null'. Re-evaluate supporting | 401 // JSON serialization encodes them as 'null'. Re-evaluate supporting |
| 402 // them if we add an API that could reasonably take them as a parameter. | 402 // them if we add an API that could reasonably take them as a parameter. |
| 403 if (isNaN(instance) || | 403 if (isNaN(instance) || |
| 404 instance == Number.POSITIVE_INFINITY || | 404 instance == Number.POSITIVE_INFINITY || |
| 405 instance == Number.NEGATIVE_INFINITY ) | 405 instance == Number.NEGATIVE_INFINITY ) |
| 406 this.addError(path, "numberFiniteNotNan", [instance]); | 406 this.addError(path, "numberFiniteNotNan", [instance]); |
| 407 | 407 |
| 408 if (schema.minimum && instance < schema.minimum) | 408 if (schema.minimum !== undefined && instance < schema.minimum) |
| 409 this.addError(path, "numberMinValue", [schema.minimum]); | 409 this.addError(path, "numberMinValue", [schema.minimum]); |
| 410 | 410 |
| 411 if (schema.maximum && instance > schema.maximum) | 411 if (schema.maximum !== undefined && instance > schema.maximum) |
| 412 this.addError(path, "numberMaxValue", [schema.maximum]); | 412 this.addError(path, "numberMaxValue", [schema.maximum]); |
| 413 | 413 |
| 414 // Check for integer values outside of -2^31..2^31-1. | 414 // Check for integer values outside of -2^31..2^31-1. |
| 415 if (schema.type === "integer" && (instance | 0) !== instance) | 415 if (schema.type === "integer" && (instance | 0) !== instance) |
| 416 this.addError(path, "numberIntValue", []); | 416 this.addError(path, "numberIntValue", []); |
| 417 | 417 |
| 418 if (schema.maxDecimal && instance * Math.pow(10, schema.maxDecimal) % 1) | 418 if (schema.maxDecimal && instance * Math.pow(10, schema.maxDecimal) % 1) |
| 419 this.addError(path, "numberMaxDecimal", [schema.maxDecimal]); | 419 this.addError(path, "numberMaxDecimal", [schema.maxDecimal]); |
| 420 }; | 420 }; |
| 421 | 421 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 442 */ | 442 */ |
| 443 chromeHidden.JSONSchemaValidator.prototype.addError = function( | 443 chromeHidden.JSONSchemaValidator.prototype.addError = function( |
| 444 path, key, replacements) { | 444 path, key, replacements) { |
| 445 this.errors.push({ | 445 this.errors.push({ |
| 446 path: path, | 446 path: path, |
| 447 message: chromeHidden.JSONSchemaValidator.formatError(key, replacements) | 447 message: chromeHidden.JSONSchemaValidator.formatError(key, replacements) |
| 448 }); | 448 }); |
| 449 }; | 449 }; |
| 450 | 450 |
| 451 })(); | 451 })(); |
| OLD | NEW |