diff options
| author | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-08 23:43:35 -0400 |
|---|---|---|
| committer | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-08 23:44:17 -0400 |
| commit | 62ee0595346e5254c10083e43346be40dbb96d70 (patch) | |
| tree | 8c70d1256edcf64c844af702296a7c5f1252716f /app/node_modules/okschema | |
| parent | f8f9c515cd9c413323f64692fd0528877a8fceed (diff) | |
Properly handle and display form errors
Diffstat (limited to 'app/node_modules/okschema')
| -rw-r--r-- | app/node_modules/okschema/index.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js index 0829807..4e8ea73 100644 --- a/app/node_modules/okschema/index.js +++ b/app/node_modules/okschema/index.js @@ -24,8 +24,14 @@ var types = { 'enum': { parent: {type: 'string'}, assertValid: function(spec, value) { - if (~spec.options.indexOf(value)) { - throw [] + value = value || ''; + if (spec.options.indexOf(value.trim()) === -1) { + throw [{ + constraint: 'enum', + actual: value, + expected: JSON.stringify(spec.options), + message: 'Invalid value' + }]; } } } |
