Releases: smikhalevski/doubter
v2.1.0
Changelog: v2.0.0...v2.1.0
-
_getInputTypes
and_getInputValues
were merged into the_getInputs
method, so literal values and types are in the same array. The result of_getInputs
can be accessed via the publicinputs
property. -
Input
andOutput
helper types infer shape input and output types respectively. Shape input and output types can still be inferred using a property syntax, but property names were changed to__input
and__output
.
v2.0.0
Changelog: v1.2.0...v2.0.0
-
Set
,Map
, andPromise
are now separate types in the type system. -
ValidationError
accepts a message argument in the constructor.formatIssues
static method toValidationError
formats issues as a human-readable error message if a message argument is omitted when constructing a newValidationError
instance. -
Composite async shapes are now applied sequentially. For example, array elements are parsed one at a time.
-
String
,Number
, andBoolean
instances are unwrapped during coercion. -
Coercion methods return
d.NEVER
to indicate that coercion isn't possible. -
ObjectShape.isPlain
returnstrue
if the shape only accepts objects withnull
orObject
prototype. -
StringShape.regex
built-in check uses a regex source as a key. -
IntersectionShape
andUnionShape
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 thePipeShape
, instead of being a self-sufficient composite. -
Callbacks passed to
catch
,refine
,check
, andtransform
receives input, issues, options, and other intermediate parsing details. -
All properties of the
Issue
interface are now optional, andPartial<Issue>
isn’t used anymore. -
Removed
isMultipleOf
: it caused themultipleOf
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
andRecordShape
don’t allow arrays anymore. -
JSONShape
was removed. I plan to move it to a separate package.
v1.2.0
Changelog: v1.1.1...v1.2.0
-
deepPartial
method was added for all object-like, composite, and proxy shapes. -
All built-in checks (aka constraints) are now always unsafe.
-
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
-
BrandShape
interface was added to preserve the deep partial protocol of the underlying shape. -
IncludeShape
interface was added (an alias forReplaceShape
) that allows the same value as an input as an output. -
TypeConstraintOptions
was removed in favor ofConstraintOptions
. -
createIssueFactory
export was removed. -
Opaque*Shape
types were removed.
v1.1.1
-
Added
exports
section to package.json.
v1.1.0
-
Dedicated const shape for better performance.
-
finite
,nan
,nonPositive
,nonNegative
,min
andmax
checks were added to number shape. -
Number shape now allows infinite values by default, use
finite
to constraint input values. -
Fixed rounding errors in
multipleOf
when used with float dividers. -
Public API members
apply
andapplyAsync
were renamed to_apply
and_applyAsync
and made protected. -
bool
alias was added forboolean
. -
lazyAsync
was removed sincelazy
can detect async shapes. -
preprocess
was renamed totransform
. -
fn
was renamed toguard
. -
The stricter algorithm to detect native enums in enum shape.
-
Removed
Shape.typeof
, all type-related APIs are now private. -
getCheck
anddeleteCheck
were added to manipulate checks. -
RedirectShape
was renamed toPipeShape
. -
Union shapes now uses a much faster lookup algorithm for discriminated unions.
-
Replaced
tslib
runtime dependency with internal__extends
implementation.