Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

JsonError no longer needs the value

  • Loading branch information...
commit 77817fb16c8395c2a9ee8a9bf7b770eb0ea7794b 1 parent 5d9ee89
Scott Bronson authored October 06, 2011

Showing 1 changed file with 13 additions and 13 deletions. Show diff stats Hide diff stats

  1. 26  lib/valid.js
26  lib/valid.js
@@ -247,7 +247,7 @@ Valid.max  = Valid.le;
247 247
 
248 248
 // JSON Schema
249 249
 
250  
-Valid.JsonError = function(path, value, message) {
  250
+Valid.JsonError = function(path, message) {
251 251
     var error = this._errors;
252 252
     var last = path.length - 1;
253 253
     var key = path.length === 0 ? '.' : path[last];
@@ -264,7 +264,7 @@ Valid.JsonError = function(path, value, message) {
264 264
 
265 265
 Valid.JsonObject = function(path, value, schema) {
266 266
     if(typeof value !== 'object') {
267  
-        this.JsonError(path, value, "must be an object");
  267
+        this.JsonError(path, "must be an object");
268 268
         return;
269 269
     }
270 270
 
@@ -273,14 +273,14 @@ Valid.JsonObject = function(path, value, schema) {
273 273
         if(key in value) {
274 274
             this.JsonField(path.concat(key), value[key], schema[key]);
275 275
         } else {
276  
-            this.JsonError(path, value, "must include " + key);
  276
+            this.JsonError(path, "must include " + key);
277 277
         }
278 278
         if(this._errorCount > this._maxErrors) break;
279 279
     }
280 280
 
281 281
     for(key in value) {
282 282
         if(!value.hasOwnProperty(key)) continue;
283  
-        if(!(key in schema)) this.JsonError(path, value, "can't include " + key);
  283
+        if(!(key in schema)) this.JsonError(path, "can't include " + key);
284 284
         if(this._errorCount > this._maxErrors) break;
285 285
     }
286 286
 };
@@ -292,37 +292,37 @@ Valid.JsonField = function(path, value, schema) {
292 292
         case 'number':
293 293
         case 'boolean':
294 294
         case 'undefined':
295  
-        if(value !== schema) this.JsonError(path, value, "must equal " + this.Escape(schema));
  295
+        if(value !== schema) this.JsonError(path, "must equal " + this.Escape(schema));
296 296
         break;
297 297
 
298 298
         case 'function':
299 299
         if(schema instanceof RegExp) {
300 300
             var reresult = Valid.match(schema).check(value);
301  
-            if(reresult) this.JsonError(path, value, reresult);
  301
+            if(reresult) this.JsonError(path, reresult);
302 302
         } else {
303 303
             var fresult = schema.call(this, value);
304  
-            if(fresult) this.JsonError(path, value, fresult);
  304
+            if(fresult) this.JsonError(path, fresult);
305 305
         }
306 306
         break;
307 307
 
308 308
         case 'null':         // usually typeof null === 'object'
309 309
         case 'object':
310 310
         if(schema === null) {
311  
-            if(value !== null) this.JsonError(path, value, "must be null");
  311
+            if(value !== null) this.JsonError(path, "must be null");
312 312
         } else if(schema._queue && typeof schema.GetChain === 'function') {   // try to detect a Valid chain
313 313
             var vresult = schema.check(value);
314  
-            if(vresult) this.JsonError(path, value, vresult);
  314
+            if(vresult) this.JsonError(path, vresult);
315 315
         } else if(value === null) {
316  
-            this.JsonError(path, value, "can't be null");
  316
+            this.JsonError(path, "can't be null");
317 317
         } else if(schema instanceof Array) {
318 318
             if(value instanceof Array) {
319  
-                if(value.length !== schema.length) this.JsonError(path, value, " must have " + value.length + " items, not " + schema.length);
  319
+                if(value.length !== schema.length) this.JsonError(path, " must have " + value.length + " items, not " + schema.length);
320 320
                 for(var i=0; i < schema.length; i++) {
321 321
                     this.JsonField(path.concat(i), value[i], schema[i]);
322 322
                     if(this._errorCount > this._maxErrors) break;
323 323
                 }
324 324
             } else {
325  
-                this.JsonError(path, value, "must be an array");
  325
+                this.JsonError(path, "must be an array");
326 326
             }
327 327
         } else {
328 328
             this.JsonObject(path, value, schema);
@@ -330,7 +330,7 @@ Valid.JsonField = function(path, value, schema) {
330 330
         break;
331 331
 
332 332
         default:
333  
-        this.JsonError(path, value, "Error in template: what is " + (typeof schema) + "?");
  333
+        this.JsonError(path, "Error in template: what is " + (typeof schema) + "?");
334 334
     }
335 335
 };
336 336
 

0 notes on commit 77817fb

Please sign in to comment.
Something went wrong with that request. Please try again.