I'm looking for a way to validate dynamic objects. The dynamic objects are used in an internal API. I know that I can
- convert to XML and use XSD for validation
- convert to JSON and use Json.NET .IsValid(schema) or the Json.NET Schema package
- validate each property in code like HasProperty as shown here
The XML and JSON based approaches requires serialization and deserialization and this will impact performance when used frequently. The code based validation is difficult to maintain (in particular for hierarchical objects) and can't be used easily by API consumers.
I was looking to find something similar to XSD validation but natively for dynamic objects but had no luck. I'm fine if it is limited to ExpandoObjects.
My minimum requirements:
- identify missing required properties
- identify properties which are not specified
- allow optional properties
- allow nested objects