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

Can't pass abortEarly (or other options) down to joi via schema.validate #13

Closed
rochal opened this issue Nov 19, 2015 · 3 comments
Closed
Labels

Comments

@rochal
Copy link

rochal commented Nov 19, 2015

Hi,

Joi supports abortEarly flag to return only first error that occured when validating the schema. This is by default set to true. This can be passed to joi passed via:

Joi.validate({firstName: 'John', lastName: 'Doe', age: 45}, schema, { abortEarly: false } , function (error, value) {
    error && console.log(error);
});

When using schema.validate() we lose the option to pass in options down to Joi:

schema.validate({firstName: 'John', lastName: 'Doe', age: 45}, function (error, value) {
    error && console.log(error);
});

Without having to add Joi as dependency, is there a away for enjoi to pass options down to joi?

@tlivings tlivings added the bug label Dec 12, 2015
@tlivings
Copy link
Owner

Sorry for taking so long to respond. Will look into this!

@tlivings
Copy link
Owner

You should be able to still call Joi.validate and pass this returned schema and options.

@tlivings
Copy link
Owner

Closing this, since this simply returns the joi schema and if calling validate on schema directly (as opposed to Joi.validate) doesn't support options, it's because Joi does not.

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

No branches or pull requests

2 participants