Chromium Code Reviews| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 const std::string& s1); | 97 const std::string& s1); |
| 98 static std::string FormatErrorMessage(const std::string& format, | 98 static std::string FormatErrorMessage(const std::string& format, |
| 99 const std::string& s1, | 99 const std::string& s1, |
| 100 const std::string& s2); | 100 const std::string& s2); |
| 101 | 101 |
| 102 // Verifies if |schema| is a valid JSON v3 schema. When this validation passes | 102 // Verifies if |schema| is a valid JSON v3 schema. When this validation passes |
| 103 // then |schema| is valid JSON that can be parsed into a DictionaryValue, | 103 // then |schema| is valid JSON that can be parsed into a DictionaryValue, |
| 104 // and that DictionaryValue can be used to build a JSONSchemaValidator. | 104 // and that DictionaryValue can be used to build a JSONSchemaValidator. |
| 105 // Returns the parsed DictionaryValue when |schema| validated, otherwise | 105 // Returns the parsed DictionaryValue when |schema| validated, otherwise |
| 106 // returns NULL. In that case, |error| contains an error description. | 106 // returns NULL. In that case, |error| contains an error description. |
| 107 // If |ignore_unknown_attributes| is true then unrecognized entries in the | |
| 108 // schema will be ignored; otherwise, they'll cause a fatal parsing error. | |
| 107 static scoped_ptr<base::DictionaryValue> IsValidSchema( | 109 static scoped_ptr<base::DictionaryValue> IsValidSchema( |
| 108 const std::string& schema, | 110 const std::string& schema, |
| 111 bool ignore_unknown_attributes, | |
|
not at google - send to devlin
2013/12/06 18:12:26
pls make this an enum like the JSONWriter has (Opt
Joao da Silva
2013/12/08 08:41:20
Done.
| |
| 109 std::string* error); | 112 std::string* error); |
| 110 | 113 |
| 111 // Creates a validator for the specified schema. | 114 // Creates a validator for the specified schema. |
| 112 // | 115 // |
| 113 // NOTE: This constructor assumes that |schema| is well formed and valid. | 116 // NOTE: This constructor assumes that |schema| is well formed and valid. |
| 114 // Errors will result in CHECK at runtime; this constructor should not be used | 117 // Errors will result in CHECK at runtime; this constructor should not be used |
| 115 // with untrusted schemas. | 118 // with untrusted schemas. |
| 116 explicit JSONSchemaValidator(base::DictionaryValue* schema); | 119 explicit JSONSchemaValidator(base::DictionaryValue* schema); |
| 117 | 120 |
| 118 // Creates a validator for the specified schema and user-defined types. Each | 121 // Creates a validator for the specified schema and user-defined types. Each |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 bool default_allow_additional_properties_; | 229 bool default_allow_additional_properties_; |
| 227 | 230 |
| 228 // Errors accumulated since the last call to Validate(). | 231 // Errors accumulated since the last call to Validate(). |
| 229 std::vector<Error> errors_; | 232 std::vector<Error> errors_; |
| 230 | 233 |
| 231 | 234 |
| 232 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator); | 235 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator); |
| 233 }; | 236 }; |
| 234 | 237 |
| 235 #endif // COMPONENTS_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_H_ | 238 #endif // COMPONENTS_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_H_ |
| OLD | NEW |