theleoborges / bouncer

A validation DSL for Clojure & Clojurescript applications
364 stars 38 forks source link

Adding a maximum length validtion for strings #29

Closed edgibbs closed 9 years ago

edgibbs commented 9 years ago

Just adding a maximum length validation for strings.

theleoborges commented 9 years ago

Any reason this validator applies to strings only?

edgibbs commented 9 years ago

I didn't have any use cases for testing the length of anything other than strings.

theleoborges commented 9 years ago

Fair enough. The implementation could easily be updated to work with any sequences however. That would make it more reusable - if you need it to be a string you could combine both v/string (merged recently) and your v/max-length.

Additionally, I'd rename max-length to count.

What do you think? If you update the PR, I'm happy to merge it. You might need to pull as other PR's have been merged since you first submitted this one.

Thanks

edgibbs commented 9 years ago

Sounds good, I'll take a look at it tomorrow.

theleoborges commented 9 years ago

Awesome. Thanks. On 20/01/2015 4:15 pm, "Ed Gibbs" notifications@github.com wrote:

Sounds good, I'll take a look at it tomorrow.

— Reply to this email directly or view it on GitHub https://github.com/leonardoborges/bouncer/pull/29#issuecomment-70605720.

robinheghan commented 9 years ago

I was wondering, if it wasn't to much trouble, could you create a min-length validator as well? If you don't have the time I could probably do it :)

edgibbs commented 9 years ago

OK, I'll add the min as well, but any preference on the names:

robinheghan commented 9 years ago

My preference is min-length and max-length

theleoborges commented 9 years ago

My preference is max-count and min-count.

My reasoning for this is that Clojure already has a count function which works on sequences, therefore they seem more intuitive.

robinheghan commented 9 years ago

I don't have a strong preference, and leonardoborges makes a fair point.

robinheghan commented 9 years ago

Changes look good to me :+1: