longshotlabs / simpl-schema

A JavaScript schema validation package that supports direct validation of MongoDB update modifier objects
https://www.npmjs.com/package/simpl-schema
MIT License
560 stars 114 forks source link

minCount/maxCount for number/date length. #253

Open janat08 opened 6 years ago

janat08 commented 6 years ago

Would be nice if minCount and maxCount would be available to check for length of number/date as string length, where you'd probably also convert strings to count validators instead reserving min/max for actual ranges.

aldeed commented 6 years ago

I'm not sure I understand this. Can you post some example schemas and data?

janat08 commented 6 years ago

as in when u measure the length of string/number/integer it should logically be minCount/maxCount.

On Tue, Apr 17, 2018 at 3:44 AM, Eric Dobbertin notifications@github.com wrote:

I'm not sure I understand this. Can you post some example schemas and data?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aldeed/simple-schema-js/issues/253#issuecomment-381759955, or mute the thread https://github.com/notifications/unsubscribe-auth/AKz-ga6OoOypsxyf6rMcUtQSQQgNrrbUks5tpRCsgaJpZM4TVD9X .

aldeed commented 6 years ago

The reasons for this might go back to when you could define array and array item in the same definition, which isn't possible anymore. So it might be possible to use a clearer name like minLength for string character length.

I'm not sure what you mean by measuring the "length" of a number. The number of digits? That would be a new feature, but I can't think of why you would want to do that.

janat08 commented 6 years ago

Some numbers are better expressed in length.