jquense / yup

Dead simple Object schema validation
MIT License
22.94k stars 935 forks source link

`defined` does not allow `null` #2235

Closed GravlLift closed 3 months ago

GravlLift commented 4 months 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 3 months 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()