NewOldMax / react-form-validator-core

Core validator component for react forms
MIT License
95 stars 44 forks source link

Bugfix / Strict null comparison on isEmpty #8

Closed HeberLZ closed 6 years ago

HeberLZ commented 6 years ago

Hi there,

I just updated the null check to make sure it's a strict comparison in order to prevent other falsy values from being accounted as empty and added an empty array check in case the value to be validated is an array, which is the case in the project I'm currently working on :)

Cheers!

NewOldMax commented 6 years ago

Hi, thanks for your PR. Can you show an example where this case is relevant? It's not common to use arrays as input values. Maybe it's better to keep this in Custom rules

HeberLZ commented 6 years ago

I'm really sorry about this, created this pr a long time ago and somehow never saw your response with all the notifications, the use-case would be a SelectValidator with multiple=true, where the value would be an array. The same thing would happen when building a custom validator for the chip input which is not included in material-ui

NewOldMax commented 6 years ago

I think it's better to have different rule, like isEmptyArray. Otherwise we can have very complex isEmpty in future, like checking empty objects etc

HeberLZ commented 6 years ago

Makes sense, removed empty array check

NewOldMax commented 6 years ago

Thanks for your work