OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_COMMON_JSON_SCHEMA_VALIDATOR_H_ | 5 #ifndef CHROME_COMMON_JSON_SCHEMA_VALIDATOR_H_ |
6 #define CHROME_COMMON_JSON_SCHEMA_VALIDATOR_H_ | 6 #define CHROME_COMMON_JSON_SCHEMA_VALIDATOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Creates a validator for the specified schema and user-defined types. Each | 106 // Creates a validator for the specified schema and user-defined types. Each |
107 // type must be a valid JSONSchema type description with an additional "id" | 107 // type must be a valid JSONSchema type description with an additional "id" |
108 // field. Schema objects in |schema| can refer to these types with the "$ref" | 108 // field. Schema objects in |schema| can refer to these types with the "$ref" |
109 // property. | 109 // property. |
110 // | 110 // |
111 // NOTE: This constructor assumes that |schema| and |types| are well-formed | 111 // NOTE: This constructor assumes that |schema| and |types| are well-formed |
112 // and valid. Errors will result in CHECK at runtime; this constructor should | 112 // and valid. Errors will result in CHECK at runtime; this constructor should |
113 // not be used with untrusted schemas. | 113 // not be used with untrusted schemas. |
114 JSONSchemaValidator(DictionaryValue* schema, ListValue* types); | 114 JSONSchemaValidator(DictionaryValue* schema, ListValue* types); |
115 | 115 |
| 116 ~JSONSchemaValidator(); |
| 117 |
116 // Whether the validator allows additional items for objects and lists, beyond | 118 // Whether the validator allows additional items for objects and lists, beyond |
117 // those defined by their schema, by default. | 119 // those defined by their schema, by default. |
118 // | 120 // |
119 // This setting defaults to false: all items in an instance list or object | 121 // This setting defaults to false: all items in an instance list or object |
120 // must be defined by the corresponding schema. | 122 // must be defined by the corresponding schema. |
121 // | 123 // |
122 // This setting can be overridden on individual object and list schemas by | 124 // This setting can be overridden on individual object and list schemas by |
123 // setting the "additionalProperties" field. | 125 // setting the "additionalProperties" field. |
124 bool default_allow_additional_properties() const { | 126 bool default_allow_additional_properties() const { |
125 return default_allow_additional_properties_; | 127 return default_allow_additional_properties_; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 bool default_allow_additional_properties_; | 204 bool default_allow_additional_properties_; |
203 | 205 |
204 // Errors accumulated since the last call to Validate(). | 206 // Errors accumulated since the last call to Validate(). |
205 std::vector<Error> errors_; | 207 std::vector<Error> errors_; |
206 | 208 |
207 | 209 |
208 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator); | 210 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator); |
209 }; | 211 }; |
210 | 212 |
211 #endif // CHROME_COMMON_JSON_SCHEMA_VALIDATOR_H_ | 213 #endif // CHROME_COMMON_JSON_SCHEMA_VALIDATOR_H_ |
OLD | NEW |