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

Unified Diff: components/policy/core/common/schema.h

Issue 139853013: Improve error message display for Schema::Validate() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@expand-policy-schema-3
Patch Set: fix comments Created 6 years, 11 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
Index: components/policy/core/common/schema.h
diff --git a/components/policy/core/common/schema.h b/components/policy/core/common/schema.h
index 169fff5bc3651459c653ecdf340ac9e677d28fbb..2d922000a1cbc700ba34fbefdd3cefffe9673de7 100644
--- a/components/policy/core/common/schema.h
+++ b/components/policy/core/common/schema.h
@@ -79,18 +79,21 @@ class POLICY_EXPORT Schema {
// Validate |value| against current schema, |strategy| is the strategy to
// handle unknown properties or invalid values. Allowed errors will be
- // ignored. If |value| don't conform the schema, false will be returned and
- // |error| will contain the detailed reason.
+ // ignored. |error_path| and |error| will contain the last error location and
+ // detailed message if |value| doesn't strictly conform to the schema. If
+ // |value| doesn't conform to the schema even within the allowance of
+ // |strategy|, false will be returned and |error_path| and |error| will
+ // contain the corresponding error that caused the failure. |error_path| can
+ // be NULL and in that case no error path will be returned.
bool Validate(const base::Value& value,
SchemaOnErrorStrategy strategy,
+ std::string* error_path,
std::string* error) const;
- // Validate |value| against current schema, |strategy| is the strategy to
- // handle unknown properties or invalid values. Allowed errors will be
- // dropped in place. If |value| don't conform the schema, false will be
- // returned and |error| will contain the detailed message.
+ // Same as Validate() but drop values with errors instead of ignoring them.
bool Normalize(base::Value* value,
SchemaOnErrorStrategy strategy,
+ std::string* error_path,
std::string* error) const;
// Used to iterate over the known properties of TYPE_DICTIONARY schemas.
@@ -152,7 +155,7 @@ class POLICY_EXPORT Schema {
const internal::SchemaNode* node);
bool ValidateIntegerRestriction(int index, int value) const;
- bool ValidateStringRestriction(int index, const char *str) const;
+ bool ValidateStringRestriction(int index, const char* str) const;
scoped_refptr<const InternalStorage> storage_;
const internal::SchemaNode* node_;
« no previous file with comments | « no previous file | components/policy/core/common/schema.cc » ('j') | components/policy/core/common/schema_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698