Schema validation for multiple types of subdocuments

I’d like to use validation for an object that has several variants (polymorphic) it would seem that oneOf is the place to implement this (by my understanding), but I don’t see any examples of that in the documentation.

Could someone fill me in on this please?

Hello @Ilan_Toren ,

To learn more about oneOf, please go through Video: Schema Validation and read below threads on oneOf usage.

https://www.mongodb.com/community/forums/community/forums/t/multiple-json-schemas-with-oneof/97856?u=tarun_gaur

In case you have queries or issues with this, please feel free to reach out with below details

  • MongoDB Version
  • Some example documents which should pass the schema validation

Regards,
Tarun

Thanks for answering. Looks good

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.