On 23 December 2013 13:23, Geoffrey Roguelon
<[email protected]> wrote:
> Hi,
>
> I searched any topics about the option 'in' for the numeric validations in
> the models but I found nothing. Thus, I suggest to add the ability to define
> the options of the validation with help of Range of Numeric values. The
> benefit will be the reduction of validation size in the models simplifying
> maintenance and reading of the code.
>
> We could change this code:
>
> class Person
>   validates_numericality_of :age, greater_than_or_equal_to: 1,
> less_than_or_equal_to: 100
> end
>
>
> by:
>
> class Person
>   validates_numericality_of :age, in: 1..100
> end

Does something like
validates :age, :inclusion => { :in => 0..100 }
do what you want?

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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 http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to