There's also the little issue of the world not all using only English.  A 
full Unicode-aware case insensitivity is even more inefficient than a 
regular ascii-only one... but in practice might be required in just as many 
cases as an ascii one...

Dave

On Tuesday, October 2, 2012 12:15:25 PM UTC-7, Godfrey Chan wrote:
>
> Is there a use case where you wouldn't just do something like...
>
> validates :numbers, inclusion: { in: ['one', 'two'] }
>
> def numbers
>   read_attribute(:numbers).try(:downcase)
> end
>
> i.e. Is there a particular reason why you still want the values to be 
> stored/presented with potentially different cases, but want the validation 
> to be case insensitive?
>
> I couldn't think of a lot of these use cases, so I have reservations on 
> putting this in core. Plus it seems quite easy to implement yourself?
>
> Also, how do you plan to implement this? It seems like your only option is 
> to call .to_a on the in/within option into an Array, and then call 
> .map(&:downcase) on each element. This has several problems:
>
> 1. In extreme cases, this might be very inefficient. (e.g. When the input 
> is a large Range)
>
> 2. What if the option cannot be turned into an Array at all? I know in the 
> docs it says it has to be at least an Enumerable, but the code only 
> requires the object to respond to #include?. This wouldn't work when I do 
> something like:
>
> class SimplePasswordChecker
>   def include?( password )
>     # Check length of password
>     # Check against some dictionary
>     # Return true if the password is to simple...
>   end
> end
>
> validates :password, exclusion: { in: SimplePasswordChecker.new, 
> case_insensitive: true }, on: :create
>
> 3. What if the options in the array are not strings? Do you call .to_s and 
> then .downcase ?
>
>
> Given the a) the use case seems quite rare, b) it's easy to implement 
> yourself, c) the solution can't be very generic/robust against all input 
> values, my vote is -1.
>
> On 2012-10-01, at 10:49 PM, Nihad Abbasov wrote:
>
> I want to add case_sensitive option to inclusion validation. This will 
> allow to do: 
>
> validates :numbers, :inclusion => { :in => %(One Two), :case_sensitive => 
> false }
>
> Does it make a sense?
>
> Thanks.
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Core" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/rubyonrails-core/-/zDjBZYxNen0J.
> To post to this group, send email to rubyonra...@googlegroups.com<javascript:>
> .
> To unsubscribe from this group, send email to 
> rubyonrails-co...@googlegroups.com <javascript:>.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-core?hl=en.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/k59MIPbuZ-cJ.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to