Skip to content

v2.0.0

Compare
Choose a tag to compare
@github-actions github-actions released this 09 Mar 21:50

Changelog: v1.2.0...v2.0.0

  • Shape introspection.

  • Set, Map, and Promise are now separate types in the type system.

  • Function shape.

  • Replace, allow, and deny a value.

  • Exclude a shape from another shape, or negate a shape.

  • Custom checks can be parameterized.

  • ValidationError accepts a message argument in the constructor. formatIssues static method to ValidationError formats issues as a human-readable error message if a message argument is omitted when constructing a new ValidationError instance.

  • parse and parseAsync support the errorMessage option.

  • Composite async shapes are now applied sequentially. For example, array elements are parsed one at a time.

  • String, Number, and Boolean instances are unwrapped during coercion.

  • Coercion methods return d.NEVER to indicate that coercion isn't possible.

  • Issues produced by unions are more expressive.

  • ObjectShape.isPlain returns true if the shape only accepts objects with null or Object prototype.

  • StringShape.regex built-in check uses a regex source as a key.

  • IntersectionShape and UnionShape don't apply checks if any of the underlying shapes have raised an issue.

  • PromiseShape applies unsafe checks even if the underlying shape raised an issue.

  • TransformShape is applied through the PipeShape, instead of being a self-sufficient composite.

  • Callbacks passed to catch, refine, check, and transform receives input, issues, options, and other intermediate parsing details.

  • All properties of the Issue interface are now optional, and Partial<Issue> isn’t used anymore.

  • Removed isMultipleOf: it caused the multipleOf check to be super slow and fixed a rare case. If you want to use real numbers as divisors, create a custom check that rounds the input value to a precision.

  • ObjectShape and RecordShape don’t allow arrays anymore.

  • JSONShape was removed. I plan to move it to a separate package.