Skip to content

Evolving Schema Validator #1654

@norberttech

Description

@norberttech

Currently we have only two strategies of validating schema:

  • strict - all fields must be exactly the same
  • selective - ignore extra fields addded to given that are not present in expected, otherwise the same as strict

The goal is to add third option that will be aligned with a seamless schema evolution.
Here are the rules:

  • if schemas are the same, return true
  • if given schema has less fields than expected schema, return false
  • if given schema is making a nullable field non-nullable, return false
  • if given schema is making a non-nullable field nullable, return true
  • if given schema is changing the type of a field, return false
  • if given schema is adding a field, return true

There should be also dsl function:

schema_validate(Schema $expected, Schema $given, SchemaValidator = new StrictSchemaValidator()) : bool;

Additionally (it's a small bc break) we should change the order of argumetns in SchemaValidator::isValid()

Now:

  • `isValid(Schema $given, Schema $expected) : bool;

Should be

  • isValid(Schema $expected, Schema $given) : bool

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions