Browse files

Improve the readability of the ‘validate’ method

  • Loading branch information...
1 parent 58da343 commit 4a2281d3a117c79d61d01b7fddd086355c67c3ce @Baggz committed Mar 14, 2012
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/engines/json/validate.js
View
3 src/engines/json/validate.js
@@ -63,14 +63,17 @@ Validation.prototype.validate = function(instance, schema, callback) {
* }
*/
if (objectTypes.indexOf(schema.type) !== -1) {
+
if (isString(instance)) {
try {
instance = JSON.parse(instance);
} catch(parseError) {
}
}
+
return this.validateSchema(instance, schema, '', callbackProxy);
+
}
/**

0 comments on commit 4a2281d

Please sign in to comment.