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

Unified 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: fix comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/json_schema/DEPS ('k') | components/json_schema/json_schema_validator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/json_schema/json_schema_validator.h
diff --git a/components/json_schema/json_schema_validator.h b/components/json_schema/json_schema_validator.h
index 4e8acaddfd983c68b10c02f126e29b6a498cc2ab..ad429ef3b801eba89653889cae4e00681d9be0b7 100644
--- a/components/json_schema/json_schema_validator.h
+++ b/components/json_schema/json_schema_validator.h
@@ -32,7 +32,6 @@ class Value;
// - disallow
// - union types (but replaced with 'choices')
// - number.maxDecimal
-// - string.pattern
//
// The following properties are not applicable to the interface exposed by
// this class:
@@ -52,6 +51,8 @@ class Value;
// - by default an "object" typed schema does not allow additional properties.
// if present, "additionalProperties" is to be a schema against which all
// additional properties will be validated.
+// - regular expression supports all syntaxes that re2 accepts.
+// See https://code.google.com/p/re2/wiki/Syntax for details.
//==============================================================================
class JSONSchemaValidator {
public:
@@ -92,6 +93,7 @@ class JSONSchemaValidator {
static const char kNumberMaximum[];
static const char kInvalidType[];
static const char kInvalidTypeIntegerNumber[];
+ static const char kInvalidRegex[];
// Classifies a Value as one of the JSON schema primitive types.
static std::string GetJSONSchemaType(const base::Value* value);
@@ -110,6 +112,10 @@ class JSONSchemaValidator {
// and that DictionaryValue can be used to build a JSONSchemaValidator.
// Returns the parsed DictionaryValue when |schema| validated, otherwise
// returns NULL. In that case, |error| contains an error description.
+ // For performance reasons, currently IsValidSchema() won't check the
+ // correctness of regular expressions used in "pattern" and
+ // "patternProperties" and in Validate() invalid regular expression don't
+ // accept any strings.
static scoped_ptr<base::DictionaryValue> IsValidSchema(
const std::string& schema,
std::string* error);
« no previous file with comments | « components/json_schema/DEPS ('k') | components/json_schema/json_schema_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698