You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem you are trying to fix (provide as much context as possible)
I have an issue with compare dates of certain format using .min() and .ref() methods.
Basically, what I need is comparing two dates and checking whether one is less or equal to another. There's a catch, I need to use raw() to ensure that dates are still in string format.
I would expect that payload would pass validation. But it doesn't. I get an error where .min() condition is not satisfied. When I remove raw() it works great, but I don't have dates as a string format.
Is there any way to achieve my goal with current API?
Which API (or modification of the current API) do you suggest to solve that problem ?
I'm using version 15.0.1 of @hapi/joi package together with 1.3.0 version @hapi/joi-date package, so it's not base package only.
Are you ready to work on a pull request if your suggestion is accepted ?
Yes, I would be glad to help.
The text was updated successfully, but these errors were encountered:
Since raw is applied on the value immediately after it is validated, the reference resolves into the raw value which of course fails validation. It might be easy to support in your simple case, but not in cases where the reference goes deeper than a sibling.
However, in this specific example, you can just remove raw() and ignore the converted value. If the value passes validation, use the original value because it will be in raw string format that was validated.
Describe the problem you are trying to fix (provide as much context as possible)
I have an issue with compare dates of certain format using
.min()
and.ref()
methods.Basically, what I need is comparing two dates and checking whether one is less or equal to another. There's a catch, I need to use
raw()
to ensure that dates are still in string format.Let's consider this example:
I would expect that payload would pass validation. But it doesn't. I get an error where
.min()
condition is not satisfied. When I removeraw()
it works great, but I don't have dates as a string format.Is there any way to achieve my goal with current API?
Which API (or modification of the current API) do you suggest to solve that problem ?
I'm using version 15.0.1 of
@hapi/joi
package together with 1.3.0 version@hapi/joi-date
package, so it's not base package only.Are you ready to work on a pull request if your suggestion is accepted ?
Yes, I would be glad to help.
The text was updated successfully, but these errors were encountered: