-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Validate a number, which depends on other validate numbers #667
Comments
You mustn't be familiar with javascript, you can't sum objects like that. |
@Marsup you have to admit it's a cute attempt though... |
Why not passing a function as a limit, next to number or reference? |
Such a very welcoming atmosphere here. |
Is there a recommended approach to doing this kind of validation? |
@reaktivo now joi supports extensions, I think the only way is to redefine max, references haven't evolved since the time of this issue. It may be super simple or super complex depending on the features you want to support. -- @blurpis, you could assume I was saying that with a harsh tone, or just consider I was stating a mere fact with no malice. Javascripters know that there's no such thing as operators overload and usually don't even look at mathematical operations to do stuff. There was, at the time, just no way to achieve what he wanted. Sorry if the OP felt offended by what I said. |
Is there any recommended Joi approach for summation validation. I am trying to sum array's inside of numbers. But I cant sum numbers inside array with Joi. |
As previously mentioned, an extension is probably your best bet. |
For anyone still looking for a solution, according to @hueniverse it seems now possible with joi16: https://twitter.com/eranhammer/status/1143266728497033220 |
That's correct, the RC is published but you're a bit on your own as for the migration until we write a proper guide. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
I want to validate a number, which depends on other values. I tried something like the following:
In this case c should not be greater than the value of a + b.
If I run this code, I get
The text was updated successfully, but these errors were encountered: