diff --git a/README.md b/README.md index a3dcd72f..2bbb32a7 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,8 @@ const parsedUser = await userSchema.validate( - [`Schema.withMutation(builder: (current: Schema) => void): void`](#schemawithmutationbuilder-current-schema--void-void) - [`Schema.default(value: any): Schema`](#schemadefaultvalue-any-schema) - [`Schema.getDefault(options?: object): Any`](#schemagetdefaultoptions-object-any) - - [`Schema.nullable(): Schema`](#schemanullable-schema) - - [`Schema.nonNullable(): Schema`](#schemanonnullable-schema) + - [`Schema.nullable(message?: string | function): Schema`](#schemanullable-schema) + - [`Schema.nonNullable(message?: string | function): Schema`](#schemanonnullable-schema) - [`Schema.defined(): Schema`](#schemadefined-schema) - [`Schema.optional(): Schema`](#schemaoptional-schema) - [`Schema.required(message?: string | function): Schema`](#schemarequiredmessage-string--function-schema) @@ -946,7 +946,7 @@ yup.date.default(() => new Date()); // also helpful for defaults that change ove Retrieve a previously set default value. `getDefault` will resolve any conditions that may alter the default. Optionally pass `options` with `context` (for more info on `context` see `Schema.validate`). -#### `Schema.nullable(): Schema` +#### `Schema.nullable(message?: string | function): Schema` Indicates that `null` is a valid value for the schema. Without `nullable()` `null` is treated as a different type and will fail `Schema.isType()` checks. @@ -959,7 +959,7 @@ schema.cast(null); // null InferType; // number | null ``` -#### `Schema.nonNullable(): Schema` +#### `Schema.nonNullable(message?: string | function): Schema` The opposite of `nullable`, removes `null` from valid type values for the schema. **Schema are non nullable by default**. diff --git a/src/array.ts b/src/array.ts index 3d73101c..cd94b9d4 100644 --- a/src/array.ts +++ b/src/array.ts @@ -307,7 +307,9 @@ export default interface ArraySchema< notRequired(): ArraySchema, TContext, TDefault, TFlags>; nullable(msg?: Message): ArraySchema; - nonNullable(): ArraySchema, TContext, TDefault, TFlags>; + nonNullable( + msg?: Message, + ): ArraySchema, TContext, TDefault, TFlags>; strip( enabled: false, diff --git a/src/date.ts b/src/date.ts index 34f91694..8d236019 100644 --- a/src/date.ts +++ b/src/date.ts @@ -134,7 +134,9 @@ export default interface DateSchema< notRequired(): DateSchema, TContext, TDefault, TFlags>; nullable(msg?: Message): DateSchema; - nonNullable(): DateSchema, TContext, TDefault, TFlags>; + nonNullable( + msg?: Message, + ): DateSchema, TContext, TDefault, TFlags>; strip( enabled: false, diff --git a/src/mixed.ts b/src/mixed.ts index 63b077e2..7fba52e1 100644 --- a/src/mixed.ts +++ b/src/mixed.ts @@ -73,7 +73,9 @@ export default interface MixedSchema< msg?: Message, ): MixedSchema; - nonNullable(): MixedSchema, TContext, TDefault, TFlags>; + nonNullable( + msg?: Message, + ): MixedSchema, TContext, TDefault, TFlags>; strip( enabled: false, diff --git a/src/number.ts b/src/number.ts index de97ea62..91c0932d 100644 --- a/src/number.ts +++ b/src/number.ts @@ -192,7 +192,9 @@ export default interface NumberSchema< nullable( msg?: Message, ): NumberSchema; - nonNullable(): NumberSchema, TContext, TDefault, TFlags>; + nonNullable( + msg?: Message, + ): NumberSchema, TContext, TDefault, TFlags>; strip( enabled: false, diff --git a/src/object.ts b/src/object.ts index 9ce4a879..90898973 100644 --- a/src/object.ts +++ b/src/object.ts @@ -112,7 +112,9 @@ export default interface ObjectSchema< notRequired(): ObjectSchema, TContext, TDefault, TFlags>; nullable(msg?: Message): ObjectSchema; - nonNullable(): ObjectSchema, TContext, TDefault, TFlags>; + nonNullable( + msg?: Message, + ): ObjectSchema, TContext, TDefault, TFlags>; strip( enabled: false, diff --git a/src/string.ts b/src/string.ts index a92c3d85..bfcade20 100644 --- a/src/string.ts +++ b/src/string.ts @@ -288,9 +288,11 @@ export default interface StringSchema< notRequired(): StringSchema, TContext, TDefault, TFlags>; nullable( - msg?: Message, + msg?: Message, ): StringSchema; - nonNullable(): StringSchema, TContext, TDefault, TFlags>; + nonNullable( + msg?: Message + ): StringSchema, TContext, TDefault, TFlags>; strip( enabled: false, diff --git a/src/tuple.ts b/src/tuple.ts index f4bf6443..c68a120a 100644 --- a/src/tuple.ts +++ b/src/tuple.ts @@ -58,7 +58,9 @@ export default interface TupleSchema< nullable( msg?: Message, ): TupleSchema; - nonNullable(): TupleSchema, TContext, TDefault, TFlags>; + nonNullable( + msg?: Message + ): TupleSchema, TContext, TDefault, TFlags>; strip( enabled: false,