summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 16:25:06 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 16:25:06 +0000
commit66de39d1e2b87105dc31d493060aa1a9d79c1c44 (patch)
treee7b9b438b7fa0aa201c60c80e6d7fd790159772e /chrome/renderer
parenta2446143b5ae6fdc3d7d48a605c0149f3efd91fa (diff)
downloadchromium_src-66de39d1e2b87105dc31d493060aa1a9d79c1c44.zip
chromium_src-66de39d1e2b87105dc31d493060aa1a9d79c1c44.tar.gz
chromium_src-66de39d1e2b87105dc31d493060aa1a9d79c1c44.tar.bz2
Add a few extra error messages to help catch typos in schemas.
Review URL: http://codereview.chromium.org/100113 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rwxr-xr-xchrome/renderer/resources/json_schema.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/chrome/renderer/resources/json_schema.js b/chrome/renderer/resources/json_schema.js
index 2c75e4d..5fdbd8c 100755
--- a/chrome/renderer/resources/json_schema.js
+++ b/chrome/renderer/resources/json_schema.js
@@ -71,7 +71,9 @@ chromium.JSONSchemaValidator.messages = {
numberMaxValue: "Value must not be greater than *.",
numberMaxDecimal: "Value must not have more than * decimal places.",
invalidType: "Expected '*' but got '*'.",
- invalidChoice: "Value does not match any valid type choices."
+ invalidChoice: "Value does not match any valid type choices.",
+ invalidPropertyType: "Missing property type.",
+ schemaRequired: "Schema value required.",
};
/**
@@ -121,6 +123,11 @@ chromium.JSONSchemaValidator.prototype.validate = function(instance, schema,
opt_path) {
var path = opt_path || "";
+ if (!schema) {
+ this.addError(path, "schemaRequired");
+ return;
+ }
+
// If the schema has an extends property, the instance must validate against
// that schema too.
if (schema.extends)
@@ -209,7 +216,9 @@ chromium.JSONSchemaValidator.prototype.validateObject = function(instance,
schema, path) {
for (var prop in schema.properties) {
var propPath = path ? path + "." + prop : prop;
- if (prop in instance && instance[prop] !== null &&
+ if (schema.properties[prop] == undefined) {
+ this.addError(propPath, "invalidPropertyType");
+ } else if (prop in instance && instance[prop] !== null &&
instance[prop] !== undefined) {
this.validate(instance[prop], schema.properties[prop], propPath);
} else if (!schema.properties[prop].optional) {