dry-rb / dry-schema

Coercion and validation for data structures
https://dry-rb.org/gems/dry-schema
MIT License
425 stars 110 forks source link

Fix value coercion for composed schemas #421

Closed robhanlon22 closed 2 years ago

robhanlon22 commented 2 years ago

Adds DSL#strict_type_schema. This is used when composing schemas within macros. Making them strict improves composition of schemas, especially when using the | operator. Before, all of the composed schemas were lax, and if a subschema would pass a lax check, then values would be eliminated from the coerced output that are necessary for later schema validation to succeed.

Also fixes up metadata when creating the types map for a schema to not always set required to false. This was also causing incorrect elision of required keys when composing schemas.

robhanlon22 commented 2 years ago

@solnic this would be great to get into 1.10.1! :)