trailsjs / trailpack-express

:package: Express Trailpack
MIT License
12 stars 15 forks source link

Missing validate fields #21

Open jaumard opened 8 years ago

jaumard commented 8 years ago

@mib4fun we miss some useful options with the validate feature :

errorFields - an optional object with error fields copied into every validation error response.

failAction - determines how to handle invalid requests. Allowed values are:

  • 'error' - return a Bad Request (400) error response. This is the default value.
  • 'log' - log the error but continue processing the request.
  • 'ignore' - take no action.
  • a custom error handler function with the signature function(request, reply, source, error) where:
    • request - the request object.
    • reply - the continuation reply interface.
    • source - the source of the invalid field (e.g. 'headers', 'params', 'query', 'payload').
    • error - the error object prepared for the client response (including the validation function error under error.data).

options - options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is available here). Defaults to no options.

http://hapijs.com/api#route-options If you don't have time to do it this is not a problem I just want to let you know ^^

Also need unit tests about these new fields.

jvkassi commented 8 years ago

@jaumard, hey dude! Didn't know about that. I'll try to implement it ! Don't have much time now though :disappointed:

jaumard commented 8 years ago

@mib4fun no problem at all :) it's not urgent, just nice to have.