Skip to content

Releases: smikhalevski/doubter

v2.0.0

09 Mar 21:50
Compare
Choose a tag to compare

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.

v1.2.0

30 Jan 15:46
Compare
Choose a tag to compare

Changelog: v1.1.1...v1.2.0

  1. deepPartial method was added for all object-like, composite, and proxy shapes.

  2. All built-in checks (aka constraints) are now always unsafe.

  3. Derived shapes now inherit unsafe checks:

const shape1 = d.object({ foo: d.string() }).check(
  value => {
    if (value.foo !== undefined && value.foo.length > 2) {
      return { code: 'kaputs' };
    }
  },
  { unsafe: true }
);

// 🟡 Checks of shape1 are potentially incompatible with shape2
const shape2 = shape1.deepPartial();

shape2.parse({});
// ⮕ {}

shape2.parse({ foo: 'aaa' });
// ❌ ValidationError: kaputs at /foo
  1. BrandShape interface was added to preserve the deep partial protocol of the underlying shape.

  2. IncludeShape interface was added (an alias for ReplaceShape) that allows the same value as an input as an output.

  3. TypeConstraintOptions was removed in favor of ConstraintOptions.

  4. createIssueFactory export was removed.

  5. Opaque*Shape types were removed.

v1.1.1

27 Jan 17:26
Compare
Choose a tag to compare
  1. Finite number shape factory.

  2. Added exports section to package.json.

v1.1.0

23 Jan 18:31
Compare
Choose a tag to compare
  1. Documentation overhaul.

  2. Type coercion.

  3. Date shape.

  4. Map shape.

  5. Set shape.

  6. JSON shape.

  7. Symbol shape.

  8. nan, null, undefined, void factories.

  9. Dedicated const shape for better performance.

  10. Type branding.

  11. Replace, exclude and include input and output values.

  12. Fallback values with catch.

  13. finite, nan, nonPositive, nonNegative, min and max checks were added to number shape.

  14. Number shape now allows infinite values by default, use finite to constraint input values.

  15. Fixed rounding errors inmultipleOf when used with float dividers.

  16. Public API members apply and applyAsync were renamed to _apply and _applyAsync and made protected.

  17. bool alias was added for boolean.

  18. lazyAsync was removed since lazy can detect async shapes.

  19. preprocess was renamed to transform.

  20. fn was renamed to guard.

  21. The stricter algorithm to detect native enums in enum shape.

  22. Removed Shape.typeof, all type-related APIs are now private.

  23. getCheck and deleteCheck were added to manipulate checks.

  24. RedirectShape was renamed to PipeShape.

  25. Union shapes now uses a much faster lookup algorithm for discriminated unions.

  26. Replaced tslib runtime dependency with internal __extends implementation.