Validating a nested object with a property from the parent #2074
Unanswered
markjaniczak
asked this question in
Questions & Answers
Replies: 2 comments 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
-
|
Hi I'm also having this issue, just want to check if there's anyone that already have the solution ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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:
{ "name": "My Video Stream", "hasRedundancy": true, "source": { "type": "hls", "primary": "https://some-domain.com/index.m3u8", "secondary": "https://some-domain.com/backup.m3u8" } }The
secondaryproperty in thesourceobject is only required ifhas_redundancyistrue. So I write my classes like so:But
hasRedundancyis not included in the plain object that the mySourceis created from, only in the top level plain object thatCreateStreamRequestis 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 theTypedecorator provides some parameters but they are not documented anywhere.Beta Was this translation helpful? Give feedback.
All reactions