Constraint that can select type definition based on field or annotation #138
Labels
enhancement
New feature or enhancement for the Ion Schema _specification_
requires new version
Something that should be considered for next version of the Ion Schema Specification
For a federated data model, it can be cumbersome to maintain union types as the number of models grows and becomes further decentralized. Union types can also be expensive because of the
O(n)
evaluation.For patterns such as the following, we could potentially bypass these challenges by using the relevant type information to look up the correct type.
Consider this strawman proposal. We could have a constraint such as
lookup_type
:This constraint would cause the validator to inspect the specified location, get the type name, and locate the type, and then validate the element against that type. This is more efficient than something like the following
Obviously there are a lot of details to be worked out, but I think the concept has some merit.
Some questions to consider:
type
, a separate constraint, or a new type of dynamic type reference? It could, perhaps, be useful to define something likeone_of: [string, (dynamic_type_ref from_annotation)]
.$any
in place of an unfound type? (I.e. should the application be able to say "I only want to validate things I know about, and things that I don't know about should always pass validation.")The text was updated successfully, but these errors were encountered: