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

Unified Diff: chrome/renderer/resources/json_schema.js

Issue 100113: Add a few extra error messages to help catch typos in schemas. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/json_schema.js
===================================================================
--- chrome/renderer/resources/json_schema.js (revision 14729)
+++ chrome/renderer/resources/json_schema.js (working copy)
@@ -71,7 +71,9 @@
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 @@
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 @@
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]) {
+ this.addError(propPath, "invalidPropertyType");
Aaron Boodman 2009/04/28 20:21:31 This branch will get entered when schema.propertie
Erik does not do reviews 2009/04/28 20:29:34 No. I'm looking for undefined. The problem I'm t
+ } 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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698