Add greater error handling abilities
mrDarcyMurphy opened this issue · comments
Darcy Murphy commented
The tool is very dumb so far, though it was originally intended to be multi-purpose so that you could provide a simple text message or a complex object when a validation fails.
Darcy Murphy commented
var currently = [
'present',
{ greaterThan: 0 }
]
var objectKey = [
{ present: 'Thing is required.'}
{ greaterThan: [0, 'Thing must be greater than zero.'] }
]
var arrayDescription = [
[ 'present', 'Thing is required.' ],
[ 'greaterThan', 0, 'Thing must be greater than zero.' ]
]
var objectDescription = [
{ is: 'present', orElse: 'Thing is required.' },
{ is: 'present', message: 'Thing is required.' },
{ is: 'greaterThan', what: 0, orElse: 'Thing must be greater than zero.' },
{ is: 'greaterThan', standard: 0, message: 'Thing must be greater than zero.' }
]
Darcy Murphy commented
At the moment the errors are less than useless. They're inconsistent with themselves even. This needs to be remedied.
My latest idea is to return an error object that describes what went wrong so that the user of the module can construct their error message however they wish.
Darcy Murphy commented
I've deliberately withheld from adding messaging to the-thing-is
. It's better left to an additional module.