summaryrefslogtreecommitdiff
path: root/app/node_modules/okschema/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/node_modules/okschema/index.js')
-rw-r--r--app/node_modules/okschema/index.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js
index 51783a1..0829807 100644
--- a/app/node_modules/okschema/index.js
+++ b/app/node_modules/okschema/index.js
@@ -19,7 +19,15 @@ var types = {
'text': {
parent: {type: 'string'},
// Let parent handle validation
- assertValid: function(s) {}
+ assertValid: function(spec, value) {}
+ },
+ 'enum': {
+ parent: {type: 'string'},
+ assertValid: function(spec, value) {
+ if (~spec.options.indexOf(value)) {
+ throw []
+ }
+ }
}
}
@@ -59,7 +67,7 @@ OKSchema.prototype.assertValid = function(data) {
Object.keys(data).forEach(function(prop) {
var type = spec[prop].type;
if (types[type]) {
- types[type].assertValid(data[prop]);
+ types[type].assertValid(spec[prop], data[prop]);
}
});
var result = mschema.validate(data, this.toMschema());