Changelog
1.0.0-beta.0 (2021-12-29)
ArraySchema
initial generic is the array type not the type of the array element. array<T>()
is still the inner type.null
for invalid casts.object().json().cast('{}')
array().json().cast('[]')
to mimic the previous behavior
Changelog
1.0.0-alpha.4 (2021-12-29)
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)
when()
requires then
and otherwise
to be
functions (schema: Schema) => Schema
.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
})
Changelog
0.32.10 (2021-10-11)
Changelog
0.32.9 (2021-02-17)
Changelog