Validating a nested object with a property from the parent #2074
Unanswered
markjaniczak
asked this question in
Questions & Answers
Replies: 1 comment 1 reply
-
Hi, i have this problem too... the parent information is a relevant data that can't be ignored within a complex custom contraint. What should we do? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There doesn't seem to be a straight forward way of validating a nested object based on a property from its parent or further up the tree. I'm looking for guidance on the best way to achieve this.
For example, I have the following object from a form:
The
secondary
property in thesource
object is only required ifhas_redundancy
istrue
. So I write my classes like so:But
hasRedundancy
is not included in the plain object that the mySource
is created from, only in the top level plain object thatCreateStreamRequest
is made from. I thought about using the groups feature to tackle this but that seems like double handling because I already have the data to pass to the condition in the original object. I see that the first parameter in theType
decorator provides some parameters but they are not documented anywhere.Beta Was this translation helpful? Give feedback.
All reactions