Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: components/json_schema/json_schema_validator.h

Issue 195193002: Add regular expression support in json_schema component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 // 25 //
26 // There is also an older JavaScript implementation of the same functionality in 26 // There is also an older JavaScript implementation of the same functionality in
27 // chrome/renderer/resources/json_schema.js. 27 // chrome/renderer/resources/json_schema.js.
28 // 28 //
29 // The following features of JSON Schema are not implemented: 29 // The following features of JSON Schema are not implemented:
30 // - requires 30 // - requires
31 // - unique 31 // - unique
32 // - disallow 32 // - disallow
33 // - union types (but replaced with 'choices') 33 // - union types (but replaced with 'choices')
34 // - number.maxDecimal 34 // - number.maxDecimal
35 // - string.pattern
36 // 35 //
37 // The following properties are not applicable to the interface exposed by 36 // The following properties are not applicable to the interface exposed by
38 // this class: 37 // this class:
39 // - options 38 // - options
40 // - readonly 39 // - readonly
41 // - title 40 // - title
42 // - description 41 // - description
43 // - format 42 // - format
44 // - default 43 // - default
45 // - transient 44 // - transient
46 // - hidden 45 // - hidden
47 // 46 //
48 // There are also these departures from the JSON Schema proposal: 47 // There are also these departures from the JSON Schema proposal:
49 // - null counts as 'unspecified' for optional values 48 // - null counts as 'unspecified' for optional values
50 // - 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
51 // for a value 50 // for a value
52 // - by default an "object" typed schema does not allow additional properties. 51 // - by default an "object" typed schema does not allow additional properties.
53 // if present, "additionalProperties" is to be a schema against which all 52 // if present, "additionalProperties" is to be a schema against which all
54 // additional properties will be validated. 53 // additional properties will be validated.
54 // - regular expression supports all syntaxes that re2 accepts.
55 // See https://code.google.com/p/re2/wiki/Syntax for details.
55 //============================================================================== 56 //==============================================================================
56 class JSONSchemaValidator { 57 class JSONSchemaValidator {
57 public: 58 public:
58 // Details about a validation error. 59 // Details about a validation error.
59 struct Error { 60 struct Error {
60 Error(); 61 Error();
61 62
62 explicit Error(const std::string& message); 63 explicit Error(const std::string& message);
63 64
64 Error(const std::string& path, const std::string& message); 65 Error(const std::string& path, const std::string& message);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 bool default_allow_additional_properties_; 240 bool default_allow_additional_properties_;
240 241
241 // Errors accumulated since the last call to Validate(). 242 // Errors accumulated since the last call to Validate().
242 std::vector<Error> errors_; 243 std::vector<Error> errors_;
243 244
244 245
245 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator); 246 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator);
246 }; 247 };
247 248
248 #endif // COMPONENTS_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_H_ 249 #endif // COMPONENTS_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698