Interdependent attributes #692
-
I want to specify a new validation check where :
so that the validation succeeds only if 0<a<b<10. Is there a way to achieve this? |
Beta Was this translation helpful? Give feedback.
Answered by
ssalbdivad
Mar 27, 2023
Replies: 1 comment 1 reply
-
Unfortunately, this is not currently possible via syntax alone. You'd have to use a narrowing function type for the object and compare the properties: const check = type([
{
a: "0<integer<10",
b: "0<integer<10"
},
"=>",
({ a, b }, problems) =>
a < b || !problems.mustBe("an object with a less than b")
]) There is an issue #485 in the backlog to support these kinds of relative comparisons. The more feedback we get on it, the sooner we can prioritize it! |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ssalbdivad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately, this is not currently possible via syntax alone. You'd have to use a narrowing function type for the object and compare the properties:
There is an issue #485 in the backlog to support these kinds of relative comparisons. The more feedback we get on it, the sooner we can prioritize it!