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

Side by Side Diff: chrome/common/json_schema_validator.h

Issue 10696034: Share JSON schema constants. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: ,. Created 8 years, 3 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 (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 #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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 13 #include "base/values.h"
14 namespace base {
15 class DictionaryValue;
16 class ListValue;
17 class StringValue;
18 class Value;
19 }
20 14
21 //============================================================================== 15 //==============================================================================
22 // This class implements a subset of JSON Schema. 16 // This class implements a subset of JSON Schema.
23 // See: http://www.json.com/json-schema-proposal/ for more details. 17 // See: http://www.json.com/json-schema-proposal/ for more details.
24 // 18 //
25 // There is also an older JavaScript implementation of the same functionality in 19 // There is also an older JavaScript implementation of the same functionality in
26 // chrome/renderer/resources/json_schema.js. 20 // chrome/renderer/resources/json_schema.js.
27 // 21 //
28 // The following features of JSON Schema are not implemented: 22 // The following features of JSON Schema are not implemented:
29 // - requires 23 // - requires
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 static const char kStringMinLength[]; 75 static const char kStringMinLength[];
82 static const char kStringMaxLength[]; 76 static const char kStringMaxLength[];
83 static const char kStringPattern[]; 77 static const char kStringPattern[];
84 static const char kNumberMinimum[]; 78 static const char kNumberMinimum[];
85 static const char kNumberMaximum[]; 79 static const char kNumberMaximum[];
86 static const char kInvalidType[]; 80 static const char kInvalidType[];
87 81
88 // Classifies a Value as one of the JSON schema primitive types. 82 // Classifies a Value as one of the JSON schema primitive types.
89 static std::string GetJSONSchemaType(base::Value* value); 83 static std::string GetJSONSchemaType(base::Value* value);
90 84
85 // If |schema_type| is a valid JSON schema type then |value_type| is assigned
86 // the corresponding Value type and returns true. Otherwise returns false.
87 static bool GetValueType(const std::string& schema_type,
88 base::Value::Type* value_type);
89
91 // Utility methods to format error messages. The first method can have one 90 // Utility methods to format error messages. The first method can have one
92 // wildcard represented by '*', which is replaced with s1. The second method 91 // wildcard represented by '*', which is replaced with s1. The second method
93 // can have two, which are replaced by s1 and s2. 92 // can have two, which are replaced by s1 and s2.
94 static std::string FormatErrorMessage(const std::string& format, 93 static std::string FormatErrorMessage(const std::string& format,
95 const std::string& s1); 94 const std::string& s1);
96 static std::string FormatErrorMessage(const std::string& format, 95 static std::string FormatErrorMessage(const std::string& format,
97 const std::string& s1, 96 const std::string& s1,
98 const std::string& s2); 97 const std::string& s2);
99 98
100 // Creates a validator for the specified schema. 99 // Creates a validator for the specified schema.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 bool default_allow_additional_properties_; 208 bool default_allow_additional_properties_;
210 209
211 // Errors accumulated since the last call to Validate(). 210 // Errors accumulated since the last call to Validate().
212 std::vector<Error> errors_; 211 std::vector<Error> errors_;
213 212
214 213
215 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator); 214 DISALLOW_COPY_AND_ASSIGN(JSONSchemaValidator);
216 }; 215 };
217 216
218 #endif // CHROME_COMMON_JSON_SCHEMA_VALIDATOR_H_ 217 #endif // CHROME_COMMON_JSON_SCHEMA_VALIDATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698