lukejagodzinski / meteor-astronomy-validators

https://atmospherejs.com/jagi/astronomy-validators
MIT License
11 stars 13 forks source link

notEqual validator #36

Open laurentpayot opened 8 years ago

laurentpayot commented 8 years ago

I was surprised not to see a notEqual validator that would ensure a field is different from a given value.

An obvious workaround is to use:

Validators.or([Validators.lt(<value>), Validators.gt(<value>)])

But that is quite verbose for something so basic.

lukejagodzinski commented 8 years ago

The example you provided is not what I would expect to see from the notEqual validator. The equal validator checks if a value of a field is equal to some provided value. What you wrote is an example of NotInRange validator, which maybe a good idea to implement. I would rather propose creating the range validator and not validator.

laurentpayot commented 8 years ago

Well this was just a workaround for strings and numbers as we already have required and notNull. A not validator would be fine too. I'm good with with size validators but if you want to add a range validator feel free ;)