From 62ee0595346e5254c10083e43346be40dbb96d70 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Wed, 8 Apr 2015 23:43:35 -0400 Subject: Properly handle and display form errors --- app/node_modules/okschema/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'app/node_modules/okschema/index.js') 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' + }]; } } } -- cgit v1.2.3-70-g09d2