OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_H_ | 5 #ifndef COMPONENTS_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_H_ |
6 #define COMPONENTS_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_H_ | 6 #define COMPONENTS_JSON_SCHEMA_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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // - hidden | 45 // - hidden |
46 // | 46 // |
47 // There are also these departures from the JSON Schema proposal: | 47 // There are also these departures from the JSON Schema proposal: |
48 // - null counts as 'unspecified' for optional values | 48 // - null counts as 'unspecified' for optional values |
49 // - added the 'choices' property, to allow specifying a list of possible types | 49 // - added the 'choices' property, to allow specifying a list of possible types |
50 // for a value | 50 // for a value |
51 // - by default an "object" typed schema does not allow additional properties. | 51 // - by default an "object" typed schema does not allow additional properties. |
52 // if present, "additionalProperties" is to be a schema against which all | 52 // if present, "additionalProperties" is to be a schema against which all |
53 // additional properties will be validated. | 53 // additional properties will be validated. |
54 // - regular expression supports all syntaxes that re2 accepts. | 54 // - regular expression supports all syntaxes that re2 accepts. |
55 // See https://code.google.com/p/re2/wiki/Syntax for details. | 55 // See https://github.com/google/re2/blob/master/doc/syntax.txt for details. |
56 //============================================================================== | 56 //============================================================================== |
57 class JSONSchemaValidator { | 57 class JSONSchemaValidator { |
58 public: | 58 public: |
59 // Details about a validation error. | 59 // Details about a validation error. |
60 struct Error { | 60 struct Error { |
61 Error(); | 61 Error(); |
62 | 62 |
63 explicit Error(const std::string& message); | 63 explicit Error(const std::string& message); |
64 | 64 |
65 Error(const std::string& path, const std::string& message); | 65 Error(const std::string& path, const std::string& message); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 bool default_allow_additional_properties_; | 245 bool default_allow_additional_properties_; |
246 | 246 |
247 // Errors accumulated since the last call to Validate(). | 247 // Errors accumulated since the last call to Validate(). |
248 std::vector<Error> errors_; | 248 std::vector<Error> errors_; |
249 | 249 |
250 | 250 |
251 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator); | 251 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator); |
252 }; | 252 }; |
253 | 253 |
254 #endif // COMPONENTS_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_H_ | 254 #endif // COMPONENTS_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_H_ |
OLD | NEW |