effect icon indicating copy to clipboard operation
effect copied to clipboard

Add `Schema.isSubType` for compatibility checking between schemas

Open schickling opened this issue 1 year ago • 1 comments

What is the problem this feature would solve?

When dealing with schema evolution, it can be very useful to have a way to determine whether schema B is a subtype of schema A in order to understand compatibility relationships between the two schemas.

What is the feature you are proposing to solve the problem?

It would be great if there was an additional function in the @effect/schema module along the lines of: Schema.isSubType(schemaA, schemaB): boolean

This might be not possible in all cases of the current Effect Schema system, so for now this probably requires a limitation to exclude support for Schema.transform but still would work well for schemas that can be mapped from/to JSONSchema.

Related:

  • https://github.com/IBM/jsonsubschema
  • https://dl.acm.org/doi/10.1145/3460319.3464796

What alternatives have you considered?

No response

schickling avatar Apr 30 '24 14:04 schickling

Schema.transform could be supported assuming annotations, like to generate json-schema

mikearnaldi avatar Apr 30 '24 14:04 mikearnaldi