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

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: reupload 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
« no previous file with comments | « no previous file | components/policy/core/common/schema.cc » ('j') | components/policy/core/common/schema.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2450c8ab057e28af7b38a7a463359e7ba15f14a8 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| don't conform the schema strictly. If |value|
Joao da Silva 2014/01/23 20:59:31 "if |value| doesn't strictly conform to the schema
binjin 2014/01/23 21:21:58 Done.
+ // don't conform the schema even within the allowance of |strategy|, false
Joao da Silva 2014/01/23 20:59:31 "doesn't conform to the schema [...]"
binjin 2014/01/23 21:21:58 Done.
+ // will be returned and |error_path| and |error| will contain the
+ // corresponding error caused the failure. |error_path| can be NULL and in
Joao da Silva 2014/01/23 20:59:31 "[..] error that caused the failure."
binjin 2014/01/23 21:21:58 Done.
+ // 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.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698