Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take in account the validated value #21

Open
danielo515 opened this issue Jul 17, 2018 · 2 comments
Open

Take in account the validated value #21

danielo515 opened this issue Jul 17, 2018 · 2 comments
Assignees

Comments

@danielo515
Copy link
Contributor

Hello,

One of the nicest (and importants) features of Joi is that it performs types coercion when possible.
For example, with the following Joi definition

const schema Joi.object({ 
     a: Joi.number().required()
 });

You get the following validation :

const {error, value} = schema.validate({ a: '1' });
error // => null
value // => {a: 1} the string '1' is converted to 1

As you can see, thanks to type coercion there is no error and the value has the correct types.
However, on Seneca only the error is taken in account, and if the validation passes then the original msg is provided to the handler. This is a big problem because the original message may not be 100% correct (ej: the a was a string)

Not sure if this should be fixed on seneca-joi or on seneca itself, but it is stopping us from using seneca-joi.

Regards

@rjrodger
Copy link
Collaborator

rjrodger commented Oct 3, 2018

great feature idea - but this belongs in a separate category of plugins that modify the original message - adding an issue in the seneca repo
leaving open as reminder

@rjrodger
Copy link
Collaborator

rjrodger commented Oct 3, 2018

senecajs/seneca#717

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants