ljharb / prop-types-tools

Custom React PropType validators
MIT License
671 stars 50 forks source link

`or`: fix so it works with `explicitNull` #13

Closed ljharb closed 7 years ago

ljharb commented 7 years ago

Fixes #12.

This is a bit tricky; typically, propType validators have an early pass when optional and propValue == null, and an early failure when required and propValue == null - but that prevents explicitNull from working properly.

Thus, I kept the early pass/failure for undefined, but omitted it for null and delegated that responsibility to each individual propType validator. Thoughts?