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

Validation artifacts collected from successful rules #2361

Closed
lightning003 opened this issue May 2, 2020 · 0 comments
Closed

Validation artifacts collected from successful rules #2361

lightning003 opened this issue May 2, 2020 · 0 comments
Assignees
Labels
feature New functionality or improvement
Milestone

Comments

@lightning003
Copy link

lightning003 commented May 2, 2020

Support plan

  • which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Community
  • is this issue currently blocking your project? (yes/no): yes
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: v12.16.1
  • module version: v16.1.7
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): hapi
  • any other relevant information:

How can we help?

Hello,
I want to validate multiple value ranges for single attribute. There are many ranges for single attribute and I need to validate for more than 100 attributes.
Say attribute age can have value range range1 = between 10 to 15.
attribute age can have value range range2 = between 20 to 25.

I want to validate these two rules in such a way that If I pass attribute value 11. The result can let me know yes it is valid because of range1. So when I am using this code

const range1 = Joi.number().integer().min(10).max(15).invalid(7);
const range2 = Joi.number().integer().min(20).max(25).invalid(12)

const schema = Joi.object({
age: Joi.alternatives().try(range2, range1)
})

it gives me just value as a response in case any of the passed value is in between any of the ranges. I want for which range it was successful.

Question 1 - I want error like information for any of the successful validation too OR Is it possible to set custom successful message for validation instead of just value return?

Question 2 - Joi.alternative gives error only in case of all of the passed schema fails. Is there any other way to achieve this error and success both for all schema that are validated. Please help.

@hueniverse hueniverse changed the title Custom Success Message OR Extra details on successful validate Validation artifacts collected from successful rules Jul 13, 2020
@hueniverse hueniverse self-assigned this Jul 13, 2020
@hueniverse hueniverse added the feature New functionality or improvement label Jul 13, 2020
@hueniverse hueniverse added this to the 17.2.0 milestone Jul 13, 2020
hueniverse added a commit that referenced this issue Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

2 participants