Skip to content

handle vacuous truth cases#238

Closed
liorcode wants to merge 1 commit intohueitan:masterfrom
liorcode:handle-vacuous-truth
Closed

handle vacuous truth cases#238
liorcode wants to merge 1 commit intohueitan:masterfrom
liorcode:handle-vacuous-truth

Conversation

@liorcode
Copy link
Contributor

@liorcode liorcode commented Sep 25, 2016

In certain validators (such as max length, number) when the value is undefined (or null) the validator should return success.

Currently when the value is undefined and the used validator is "number" or "max length", it causes an exception (TypeError: Cannot read property 'constructor' of undefined)

I updated the min/max length and regex validators, and added tests.

(I also believe this should be true for an empty value, but this is a breaking change so I didn't do it for now)

@coveralls
Copy link

coveralls commented Sep 25, 2016

Coverage Status

Coverage increased (+0.02%) to 93.636% when pulling f372573 on liorch88:handle-vacuous-truth into 531cb12 on huei90:master.

In regex validators (such as number) when the value is undefined (or null) the validator should return success, to comply with the html5 number input.

Since this is a breaking change, it will be enabled only using an opt-in flag called "allowEmptyValues".

I added tests and updated api.
@liorcode liorcode force-pushed the handle-vacuous-truth branch from f372573 to 4c01a62 Compare September 25, 2016 15:05
@liorcode liorcode closed this Sep 25, 2016
@liorcode liorcode deleted the handle-vacuous-truth branch September 25, 2016 15:12
@liorcode liorcode restored the handle-vacuous-truth branch September 25, 2016 15:12
@liorcode liorcode deleted the handle-vacuous-truth branch September 26, 2016 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants