Yup: noUnknown() & nullable() broken in 0.28.4

Created on 23 Apr 2020  路  10Comments  路  Source: jquense/yup

This shouldn't fail, and it didn't prior to 0.28.4:

const schema = object({
  name: string()
}).nullable().noUnknown();

schema.validate(null) // this throws "Cannot convert undefined or null to object"

I'm guessing it has something to do with https://github.com/jquense/yup/pull/579

To Reproduce

See error on 0.28.4: https://runkit.com/icflorescu/5ea1f46ebc48c6001a449316

Expected behavior

See it working correctly on 0.28.3: https://runkit.com/icflorescu/5ea1f8227abc65001a36be1f

Platform (please complete the following information):

  • Version 0.28.4

Most helpful comment

Can you please publish a new version on npm? Thanks a lot!

All 10 comments

It is related to #579.

https://github.com/jquense/yup/blob/16efe88a8953db60438f77f43bd5bf614079803d/src/object.js#L243

const unknownKeys = unknown(this.schema, value) shouldn't happen before testing for value == null

Do you want me to do a PR?

sure!

Can you please publish a new version on npm? Thanks a lot!

+1 for a release

Anything I can help with to speed up releasing the new version on npm?

Any idea when this will be released?

It was released 12 days ago, AFAIK.

@BenGale Why, did you encounter the same problem? This should be gone for yup ^0.28.5...

No sorry, all good now. I must have missed the release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

haddyo picture haddyo  路  3Comments

laurazenc picture laurazenc  路  3Comments

ScreamZ picture ScreamZ  路  4Comments

juni0r picture juni0r  路  3Comments

cfteric picture cfteric  路  3Comments