Am I correct in understanding that it is not possi...
# community-help
r
Am I correct in understanding that it is not possible to set an embedded object field as optional, but then if provided, all sub attributes should be present? I tried
foo -> optional, foo.bar -> string
but then it always complains that bar was not provided in the document (even if foo is not present)
j
If you define
foo.bar -> string
explicitly, you want to also set
optional: true
on
foo.bar
. Explicitly defined sub properties do not inherit from the parent object definition
r
Gotcha, I kind of figured already that was the case. I was hoping though that it might be possible to set the object as optional, but if present, to require it to match all expectations. Makes more sense to do this kind of validation before inserting the data I guess.