jquense / yup

Dead simple Object schema validation
MIT License
22.72k stars 925 forks source link

`defined` does not allow `null` #2235

Closed GravlLift closed 1 month ago

GravlLift commented 1 month ago

Describe the bug The README describes the defined operation as:

Require a value for the schema. All field values apart from undefined meet this requirement.

Despite this, the value of null is not valid.

To Reproduce

string().defined().isValid(null); // false

Expected behavior null is not undefined, so by the language of the readme, the reproduction should return true.

Platform (please complete the following information):

jquense commented 1 month ago

schema's are non-nullable by default, the defined only controls whether undefined is allowed. if you want to allow nulls use schema.nullable()