I recently started working with Sequel and I came across a situation where 
I wanted to validate that a model value was greater than a certain value.I 
have previously worked with ActiveRecord and knew about the 
validates_numercaility_of validator there, I noticed that Sequel didn't 
have an equivalent so I put together the following PR:

https://github.com/jeremyevans/sequel/pull/1155

It's essentially a port of ActiveRecord's validates_numericality_of 
validator, e.g.:

class Example < Sequel::Model
    validates_numericality_of :something, less_than: 123
end


Jeremy Evan's suggested a different API for this validator, and also posed 
the question of whether such validations are common enough that they should 
be included in Sequel (full details in the PR). The suggested API would 
look something like so:

class Example < Sequel::Model
    validates_less_than :something, 123
end


I prefer Jermey's suggested API, and I also believe that these validators 
would be quite commonly useful (I have used the ActiveRecord versions a 
number of time in previous projects).

What do you think?

Cheers,

Pete




-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to