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 20 matching lines...) Expand all Loading... |
31 // There are also these departures from the JSON Schema proposal: | 31 // There are also these departures from the JSON Schema proposal: |
32 // - function and undefined types are supported | 32 // - function and undefined types are supported |
33 // - null counts as 'unspecified' for optional values | 33 // - null counts as 'unspecified' for optional values |
34 // - added the 'choices' property, to allow specifying a list of possible types | 34 // - added the 'choices' property, to allow specifying a list of possible types |
35 // for a value | 35 // for a value |
36 // - by default an "object" typed schema does not allow additional properties. | 36 // - by default an "object" typed schema does not allow additional properties. |
37 // if present, "additionalProperties" is to be a schema against which all | 37 // if present, "additionalProperties" is to be a schema against which all |
38 // additional properties will be validated. | 38 // additional properties will be validated. |
39 //============================================================================== | 39 //============================================================================== |
40 | 40 |
41 (function() { | 41 var chromeHidden = natives.GetChromeHidden(); |
42 native function GetChromeHidden(); | |
43 var chromeHidden = GetChromeHidden(); | |
44 | 42 |
45 /** | 43 /** |
46 * Validates an instance against a schema and accumulates errors. Usage: | 44 * Validates an instance against a schema and accumulates errors. Usage: |
47 * | 45 * |
48 * var validator = new chromeHidden.JSONSchemaValidator(); | 46 * var validator = new chromeHidden.JSONSchemaValidator(); |
49 * validator.validate(inst, schema); | 47 * validator.validate(inst, schema); |
50 * if (validator.errors.length == 0) | 48 * if (validator.errors.length == 0) |
51 * console.log("Valid!"); | 49 * console.log("Valid!"); |
52 * else | 50 * else |
53 * console.log(validator.errors); | 51 * console.log(validator.errors); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 * |replacements| is an array of values to replace '*' characters in the | 438 * |replacements| is an array of values to replace '*' characters in the |
441 * message. | 439 * message. |
442 */ | 440 */ |
443 chromeHidden.JSONSchemaValidator.prototype.addError = function( | 441 chromeHidden.JSONSchemaValidator.prototype.addError = function( |
444 path, key, replacements) { | 442 path, key, replacements) { |
445 this.errors.push({ | 443 this.errors.push({ |
446 path: path, | 444 path: path, |
447 message: chromeHidden.JSONSchemaValidator.formatError(key, replacements) | 445 message: chromeHidden.JSONSchemaValidator.formatError(key, replacements) |
448 }); | 446 }); |
449 }; | 447 }; |
450 | |
451 })(); | |
OLD | NEW |