1.3.2 (2023-09-29)
1.3.1 (2023-09-26)
- ValidationError extends Error (bc5121b)
1.3.0 (2023-09-23)
1.2.0 (2023-05-25)
- expose printValue (#2002) (#2008) (1fadba1)
- pass options to
default(options => value)
(e5c5440), closes #1984
1.1.1 (2023-04-14)
- docs: Broken anchores (#1979) (4ed4576)
- make null validation errors consistent across schema (#1982) (f999497)
- object: excluded edges are merged when concating schema (c07b08f), closes #1969
1.1.0 (2023-04-12)
- only resolve "strip()" for schema when used as an object field (#1977) (2ba1104)
- respect context for object's children (#1971) (edfe6ac)
1.0.2 (2023-02-27)
1.0.1 (2023-02-25)
1.0.0 (2023-02-08)
Migrating from 0.x to 1.0.0: #1906
1.0.0-beta.8 (2022-11-10)
- check if field exists when generating defaults (37f686c)
- correct minor typo in README (#1760) (62786c4)
- don't return any for oneOf (74c5bc5), closes #1675
- export more types (f250109)
- string().notRequired() (#1824) (dcb4b63)
- TS 4.8 compat (bc74c34)
- types: undefined defaults produce optional outputs (1afbac0)
- add some more type exports (d5e9c99)
- Export ValidateOptions, ISchema for external use (#1812) (584df11)
- respect nullable() with oneOf (#1757) (61ec302), closes #768 #104
- simplify email validation (440db3e)
- previously
oneOf
required addingnull
explicitly to allowed values when using oneOf. Folks have found this confusing and unintuitive so I am deferring and adjusting the behavior - Use a simpler regex for email addresses that aligns with browsers, and add docs about how to override.
1.0.0-beta.7 (2022-08-20)
1.0.0-beta.6 (2022-08-20)
- change mixed generic to unknown from any (5e8e8ef)
- count stripping unknown fields as changes for object casts (2b4773c), closes #1620
- types: export more types (433a452)
1.0.0-beta.5 (2022-08-19)
- add cast nullability migration path. (#1749) (2bb099e)
- better Lazy types and deepPartial fixes (#1748) (e4ae6ed)
- The types for Lazy have changes a bit, it's unlikely that this affects anyone but it is technically a breaking change.
1.0.0-beta.4 (2022-04-10)
1.0.0-beta.3 (2022-03-09)
- 'required' no longer adds a test for most schema, to determine if a schema is required, check it's
spec.optional
andspec.nullable
values, also accessible viadescribe()
1.0.0-beta.2 (2022-01-21)
-
add originalValue to TestContext type (#1527) (fcc5ae7), closes /github.com/abnersajr/DefinitelyTyped/blob/a186d99d0c3a92424691a82130374a1b9145c7cd/types/yup/index.d.ts#L446
-
Merge next into master (#1547) (366f7d8), closes #1547 #1542 #1541 #1543 #1545
-
The builder object version of
when()
requiresthen
andotherwise
to be functions(schema: Schema) => Schema
. -
The function version of
when()
has been changed to make it easier to type. values are always passed as an array and schema, and options always the second and third argument.this
is no longer set to the schema instance. and all functions must return a schema to be type safe
string()
- .when('other', function (other) => {
- if (other) return this.required()
+ .when('other', ([other], schema) => {
+ return other ? schema.required() : schema
})
-
concat works shallowly now. Previously concat functioned like a deep merge for object, which produced confusing behavior with incompatible concat'ed schema. Now concat for objects works similar to how it works for other types, the provided schema is applied on top of the existing schema, producing a new schema that is the same as calling each builder method in order
-
docs: update readme
-
chore: update to readonly arrays and test string type narrowing
-
test: add boolean tests
-
docs: more docs
-
feat: allow mixed schema to specify type check
-
mixed
schema are no longer treated as the base class for other schema types. It hasn't been for a while, but we've done some nasty prototype slinging to make it behave like it was. Now typescript types should be 1 to 1 with the actual classes yup exposes.
In general this should not affect anything unless you are extending (via addMethod
or otherwise) mixed
prototype.
import {
- mixed,
+ Schema,
} from 'yup';
- addMethod(mixed, 'method', impl)
+ addMethod(Schema, 'method', impl)
-
chore: prep work for toggling coercion
-
Publish v1.0.0-alpha.4
-
chore: docs
-
feat!: add json() method and remove default object/array coercion
-
object and array schema no longer parse JSON strings by default, nor do they return
null
for invalid casts.
object().json().cast('{}')
array().json().cast('[]')
to mimic the previous behavior
-
feat: Make Array generic consistent with others
-
types only,
ArraySchema
initial generic is the array type not the type of the array element.array<T>()
is still the inner type. -
Publish v1.0.0-beta.0
-
docs
1.0.0-beta.1 (2022-01-03)
- flat bundles and size reductions (753abdf)
1.0.0-beta.0 (2021-12-29)
- feat!: add json() method and remove default object/array coercion (94b73c4)
- Make Array generic consistent with others (a82353f)
- types only,
ArraySchema
initial generic is the array type not the type of the array element.array<T>()
is still the inner type. - object and array schema no longer parse JSON strings by default, nor do they return
null
for invalid casts.
object().json().cast('{}')
array().json().cast('[]')
to mimic the previous behavior
1.0.0-alpha.4 (2021-12-29)
- add originalValue to TestContext type (#1527) (fcc5ae7), closes /github.com/abnersajr/DefinitelyTyped/blob/a186d99d0c3a92424691a82130374a1b9145c7cd/types/yup/index.d.ts#L446
- allow mixed schema to specify type check (3923039)
- concat() is shallow and does not merge (#1541) (a2f99d9)
- simplify base class hierarchy (#1543) (c184dcf)
- stricter
when
types and API (#1542) (da74254)
mixed
schema are no longer treated as the base class for other schema types. It hasn't been for a while, but we've done some nasty prototype slinging to make it behave like it was. Now typescript types should be 1 to 1 with the actual classes yup exposes.
In general this should not affect anything unless you are extending (via addMethod
or otherwise) mixed
prototype.
import {
- mixed,
+ Schema,
} from 'yup';
- addMethod(mixed, 'method', impl)
+ addMethod(Schema, 'method', impl)
- concat works shallowly now. Previously concat functioned like a deep merge for object, which produced confusing behavior with incompatible concat'ed schema. Now concat for objects works similar to how it works for other types, the provided schema is applied on top of the existing schema, producing a new schema that is the same as calling each builder method in order
- The builder object version of
when()
requiresthen
andotherwise
to be functions(schema: Schema) => Schema
. - The function version of
when()
has been changed to make it easier to type. values are always passed as an array and schema, and options always the second and third argument.this
is no longer set to the schema instance. and all functions must return a schema to be type safe
string()
- .when('other', function (other) => {
- if (other) return this.required()
+ .when('other', ([other], schema) => {
+ return other ? schema.required() : schema
})
1.0.0-alpha.3 (2021-12-28)
1.0.0-alpha.2 (2020-12-18)
1.0.0-alpha.1 (2020-12-18)
- remove unneeded Out type from schema (0bf9732)
1.0.0-alpha.0 (2020-12-14)
- add describe and meta to lazy, with resolve options (e56fea3)
0.32.11 (2021-10-12)
- dep ranges (2015c0f)
0.32.10 (2021-10-11)
- carry over excluded edges when concating objects (5334349), closes #1423
- fix the typo for the array length validation (#1287) (4c17508)
- missing transforms on concat (f3056f2), closes #1260
- oneOf, notOneOf swallowing multiple errors (#1434) (7842afb)
- prevent unhandled Promise rejection when returning rejected Promise inside test function (#1327) (5eda549)
- SchemaOf<>'s treatment of Date objects. (#1305) (91ace1e), closes #1243 #1302
- update lodash/lodash-es to fix CVEs flagged in 4.17.20 (#1334) (70d0b67)
- utils: use named functions for default exports (#1329) (acbb8b4)
- add resolved to params (#1437) (03584f6)
- add types to setLocale (#1427) (7576cd8), closes #1321
- allows custom types to be passed to avoid cast to ObjectSchema (#1358) (94cfd11)
0.32.9 (2021-02-17)
- types: Array required() and defined() will no longer return any (#1256) (52e5876)
- export MixedSchema to fix ts with --declarations (#1204) (67c96ae)
- types: add generic to Reference.create() (#1208) (be3d1b4)
- types: reach and getIn make last 2 arguments optional (#1194) (5cf2c48)
- do not initialize spec values with undefined (#1177) (e8e5b46), closes jquense/yup#1160 jquense/yup#1160
- types: meta() return type (e41040a)
- array handling in SchemaOf type (#1169) (e785e1a)
- types: make StringSchema.matches options optional (#1166) (b53e5f2)
- types: SchemaOf doesn't produce a union of base schema (2d71f32)
0.32.6 (2020-12-08)
0.32.5 (2020-12-07)
- types: change base.default() to any (01c6930)
0.32.4 (2020-12-07)
- types: rm base pick/omit types as they conflict with more specific ones (14e2c8c)
0.32.3 (2020-12-07)
- types: AnyObjectSchema anys (1c54665)
0.32.2 (2020-12-07)
0.32.1 (2020-12-04)
0.32.0 (2020-12-03)
concat
doesn't check for "unset" nullable or presence when merging meaning the nullability and presence will always be the same as the schema passed toconcat()
. They can be overridden if needed after concatenation- schema factory functions are no longer constructors. The classes are now also exported for extension or whatever else. e.g.
import { StringSchema, string } from 'yup'
0.31.1 (2020-12-01)
0.31.0 (2020-11-23)
- add array.length() and treat empty arrays as valid for required() (fbc158d)
- add object.pick and object.omit (425705a)
- deprecate the getter overload of
default()
(#1119) (5dae837) - more strictly coerce strings, exclude arrays and plain objects (963d2e8)
- array().required() will no longer consider an empty array missing and required checks will pass.
To maintain the old behavior change to:
array().required().min(1)
- plain objects and arrays are no long cast to strings automatically
to recreate the old behavior:
string().transform((_, input) => input != null && input.toString ? input.toString() : value);
0.30.0 (2020-11-19)
- defined() so it doesn't mark a schema as nullable (f08d507)
- IE11 clone() (#1029) (7fd80aa)
- security Fix for Prototype Pollution - huntr.dev (#1088) (15a0f43)
- uuid's regexp (#1112) (57d42a8)
- defined() now doesn't automatically allow null, this was a bug. to mimic the old behavior add nullable() to schema with defined()
0.29.3 (2020-08-04)
0.29.2 (2020-07-27)
0.29.1 (2020-05-27)
0.29.0 (2020-05-19)
- feat!: update docs to account for changes in types and add additional example (#891) (e105a71), closes #891
- For users of
@types/yup
only, no function changes but the type def change is large enough that it warranted a major bump here
0.28.5 (2020-04-30)
- allow passing of function to .matches() options/message param (#850) (16efe88)
- bug in object.noUnknown for nullish values jquense#854 (#855) (ccb7c7d)
0.28.4 (2020-04-20)
- array reaching (81e4058)
- make schema.type and array.innerType public API's (8f00d50)
- provide keys in default noUnknown message (#579) (ad5d015)
0.28.3 (2020-03-06)
0.28.0 (2019-12-16)
- #473 make concat compatible with (not)oneOf (#492) (8d21cc9)
- array path resolve for descendants (#669) (d31e34d)
- change @babel/runtime version to be a range (#488) (1c9b362), closes #486
- concat of mixed and subtype (#444) (7705972)
- default message for test with object (#453) (f1be37f)
- noUnknown() overriding (#452) (3047b33)
- string.matches() and regex global flag (#450) (a8935b7)
- synchronous conditional object validation with unknown dependencies (#598) (1081c41)
- typo README (about excludeEmptyString) (#441) (d02ff5e)
- unix epoc bug in date parser (#655) (0d14827)
- add _isFilled as overrideable
mixed
method to control required behavior (#459) (5b01f18) - add function test names to email and url (#292) (7e94395)
- aliases
optional()
andunknown()
(#460) (51e8661) - allow toggling strict() (#457) (851d421)
- allow withMutation() nesting (#456) (e53ea8c)
- do concat in mutation mode (#461) (02be4ca)
- finalize resolve() (#447) (afc5119)
- replace integer check with Number.isInteger (#405) (1c18442)
- support self references (#443) (1cac515), closes /github.com/jquense/yup/blob/d02ff5e59e004b4c5189d1b9fc0055cff45c61df/src/Reference.js#L3
- use the alternate object index path syntax if the key contains dots (fixes #536) (#539) (13e8c76)
- use Number.isInteger. This works correctly for large numbers.
Related to jquense#147
- reach() no longer resolves the returned schema meaning it's conditions have not been processed yet; prefer validateAt/castAt where it makes sense
- required no longer shows up twice in describe() output for array and strings, which also no longer override required
0.27.0 (2019-03-14)
- change @babel/runtime version to be a range (#488) (1c9b362), closes #486
- concat of mixed and subtype (#444) (7705972)
- default message for test with object (#453) (f1be37f)
- noUnknown() overriding (#452) (3047b33)
- typo README (about excludeEmptyString) (#441) (d02ff5e)
- add _isFilled as overrideable
mixed
method to control required behavior (#459) (5b01f18) - aliases
optional()
andunknown()
(#460) (51e8661) - allow toggling strict() (#457) (851d421)
- allow withMutation() nesting (#456) (e53ea8c)
- do concat in mutation mode (#461) (02be4ca)
- finalize resolve() (#447) (afc5119)
- support self references (#443) (1cac515), closes /github.com/jquense/yup/blob/d02ff5e59e004b4c5189d1b9fc0055cff45c61df/src/Reference.js#L3
- reach() no longer resolves the returned schema meaning it's conditions have not been processed yet; prefer validateAt/castAt where it makes sense
- required no longer shows up twice in describe() output for array and strings, which also no longer override required
- locale
number
config propertiesless
andmore
are nowlessThan
andmoreThan
- remove default export, there are only named exports now!
- fix message defaults for built-in tests, default is only used for
undefined
messages - fix the
describe()
method so it works with nested schemas
** Probably not breaking but we are being safe about it **
- 🎉 Add Synchronous validation! #94
** Features **
- Custom locales without import order #125
- Fix bug in browsers without symbol #132
** Breaking **
- Use native Set and lodash CloneDeep: #109
** Fixes and Features
- Better custom locale support: #105
- fix some messages: #112
- Clearer errors for common mistakes: #108
- New string validation length: #67
- 7bc01e0 [added] deep path support for
from
- be80413 [fixed] default in concat()
- 8a8cc5b [changed] remove case aliases and simplify camelCase
- f7446d2 [fixed] pass path correctly to cast()
- 9b5232a [added] allow function then/otherwise bodies
- 73858fe [changed] Don't throw on undefined values in cast()
- 69c0ad4 [fixed] array().concat() incorrectly cleared the sub-schema
- b0dd021 [changed] Split integer(), remove transform
- 758ac51 [added] string.ensure
- f2b0078 [changed] Less aggressive type coercions
- ab94510 [fixed] boxed number allowed NaN
- 816e607 [added] validation params to ValidationError
- f827822 [changed] validate() on objects won't cast nested schema with strict()
- 139dd24 [changed] lazy qualifies as a yup schema
- c553cc0 [added] options to lazy resolve
- 6c309e4 [fixed] array.ensure()
- ab78f54 [fixed] reach with lazy()
- 6e9046b [changed] clean up interface, added lazy(), and fixed object strict semantics
- f30d1e3 [fixed] bug in date min/max with ref
- 83c0656 [added] meta() and describe()
- 75739b8 [added] context sensitive reach()
- ff19720 [fixed] noUnknown and stripUnknown work and propagate to children
- 86b6446 [fixed] camelCase should maintain leading underscores
- 335eb18 [fixed] pass options to array sub schema
- f7f631d [changed] oneOf doesn't include empty values
- 0a7b2d4 [fixed] type and whitelist/blacklist checks threw inconsistent errors
- 1274a45 [changed] required() to non-exclusive
- 5bc250f [changed] don't clone unspecified object keys
- 069c6fd [added] withMutation() method
- e1d4891 [fixed] don't alias non existent fields
- 686f6b1 [changed] concat() allows mixing "mixed" and other type
breaking
test
functions are no longer passedpath
andcontext
as arguments, Instead they are now values onthis
inside the test function.- test functions are longer called with the schema as their
this
value, usethis.schema
instead.
other changes
- test functions are call with with a new context object, including, options, parent and
createError
for dynamically altering validation errors.
- document
stripUnknown
- add
recursive
option - add
noUnknown()
test to objects
- default for objects now adds keys for all fields, not just fields with non empty defaults
- bug fix
breaking
test
functions are now passedpath
andcontext
values along with the field value. Only breaks if using the callback style of defining custom validations
breaking
- the
validation()
method has been renamed totest()
and has a new signature requiring aname
argument - exclusive validations now trump the previous one instead of defering to it e.g:
string().max(10).max(15)
has a max of15
instead of10
other changes
- expose advanced signature for custom validation tests, gives finer grained control over how tests are added
- added the
abortEarly
(default:true
) option - transforms are passed an addition parameter: 'originalValue' you allow recovering from a bad transform further up the chain (provided no one mutated the value)
- fix
concat()
method and add tests
- fix validations where nullable fields were failing due to
null
values e.gstring.max()
- fix export error
breaking
- Removed the
extend
andcreate
methods. Use whatever javascript inheritance patterns you want instead. - the resolution order of defaults and coercions has changed. as well as the general handling of
null
values.- Number:
null
will coerce tofalse
whennullable()
is not specified.NaN
values will now failisType()
checks - String:
null
will coerce to''
whennullable()
is not specified - Date: Invalid dates will not be coerced to
null
, but left as invalid date, This is probably not a problem for anyone as invalid dates will also failisType()
checks
- Number:
- default values are cloned everytime they are returned, so it is impossible to share references to defaults across schemas. No one should be doing that anyway
- stopped pretending that using schemas as conditions in
when()
actually worked (it didn't)
other changes
transform()
now passes the original value to each transformer. Allowing you to recover from a bad transform.- added the
equals()
alias foroneOf
breaking
- isValid is now async, provide a node style callback, or use the promise the method returns to read the validity. This change allows for more robust validations, specifically remote ones for client code (or db queries for server code). The cast method is still, and will remain, synchronous.
other changes
- added validate method (also async) which resolves to the value, and rejects with a new ValidationError