dwightjack / vue-types

Vue Prop Types definitions
https://dwightjack.github.io/vue-types/
MIT License
571 stars 35 forks source link

validateType does not treat `null` the same as Vue does #383

Closed jason-wolfe closed 1 year ago

jason-wolfe commented 1 year ago

Describe the bug

validateType({type: t}, null) returns false, indicating that it does not pass prop validation.

To Reproduce Steps to reproduce the behavior:

  1. Invoke validateType({type: Object}, null)
  2. It will return false instead of true

Expected behavior

validateType({type: t}, null) should return true for all type constructors, in order to match Vue's prop type validation. This is specified in the documentation for both Vue 2 ("null and undefined values will pass any type validation") and Vue 3 ("(null and undefined values will allow any type)").

It is of course good to reject these for {type: t, required: true}.

Library version 5.0.2

Vue.js version Not involved in this code path.

dwightjack commented 1 year ago

Thanks! Fixed in vue-types@5.0.3.

jason-wolfe commented 1 year ago

Fantastic, thanks a ton @dwightjack !