cerebral-legacy / cerebral-module-forms

Form handling for Cerebral
http://cerebral-website.herokuapp.com/documentation/cerebral-module-forms
MIT License
12 stars 5 forks source link

isNumeric rule returns true on NaN #47

Open awei01 opened 7 years ago

awei01 commented 7 years ago

Hi, not sure if this is a desired behavior or not, but, if the isNumeric rule is passed NaN, it will return true. Technically, in the javascript world, this is working properly, but, in human terms, I think that it should return false for NaN. Thoughts?

edgesoft commented 7 years ago

@awei01 That´s a good question. I think you are right! Not sure if anyone else falls back on this though. @cerebraljs What's your take on this?

edgesoft commented 7 years ago

@awei01 Think we will leave it as this for the moment because others might have an implementation of isNumeric and counting on NaN. What do you think?

awei01 commented 7 years ago

It's up to you guys. I can workaround the issue. I can't think of a use case where anyone would want to validate something as NaN, especially in the context of a form. In any case, the documentation should be updated to reflect this gotcha.

edgesoft commented 7 years ago

@awei01 We will have another look. @christianalfoni Is updating alot of the modules to Cerebral2 so maybe a good idé to bring it in there.

awei01 commented 7 years ago

ok, sounds good.