Permalink
Browse files

The ‘type’ attribute is now fully compliant with the JSON Schema Inte…

…rnet Draft
  • Loading branch information...
1 parent 61d1b77 commit 9d573be2cbf2e78f4d53a29d2d2acc2ba74e7b67 @Baggz committed Mar 14, 2012
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/engines/json/attributes/type.js
@@ -1,8 +1,7 @@
/**
* Type
- * --------------------
*/
-Validation.prototype.addAttributeConstructor('type', function typeConstructor() {
+var typeConstructor = function typeConstructor() {
/**
* Types
@@ -31,7 +30,13 @@ Validation.prototype.addAttributeConstructor('type', function typeConstructor()
if (isArray(attributeValue)) {
var noError = attributeValue.some(function(type) {
+
+ if (!hasProperty(types, attributeValue)) {
+ throw new Error('Type ‘' + attributeValue + '’ is not supported.');
+ }
+
return types[type](propertyValue);
+
});
if (!noError) {
@@ -61,4 +66,7 @@ Validation.prototype.addAttributeConstructor('type', function typeConstructor()
};
-});
+};
+
+// Export
+Validation.prototype.addAttributeConstructor('type', typeConstructor);

0 comments on commit 9d573be

Please sign in to comment.