Case insensitive exclusion_of

I have the following validation code, however it will allow variations
in case. Like ‘Admin’ and ‘admiN’, etc

validates_exclusion_of :login, :in => %w( admin ),
:message => “is reserved for system accounts”

how can I make this validation case insensitive?

Jonathon M. wrote:

I have the following validation code, however it will allow variations
in case. Like ‘Admin’ and ‘admiN’, etc

validates_exclusion_of :login, :in => %w( admin ),
:message => “is reserved for system accounts”

how can I make this validation case insensitive?

This works

validates_format_of :login, :with =>
/^[^admin|administrator|root|sysadmin|superuser|moderator|support|god]$/i,
:message => “is reserved for system accounts”

Jonathon M. wrote:

Jonathon M. wrote:

I have the following validation code, however it will allow variations
in case. Like ‘Admin’ and ‘admiN’, etc

validates_exclusion_of :login, :in => %w( admin ),
:message => “is reserved for system accounts”

how can I make this validation case insensitive?

This works

validates_format_of :login, :with =>
/^[^admin|administrator|root|sysadmin|superuser|moderator|support|god]$/i,
:message => “is reserved for system accounts”

sorry that does not work and I did not mean to post it.

On 14/08/06, Jonathon M. [email protected] wrote:

how can I make this validation case insensitive?

Technically, it doesn’t solve the problem, rather the code avoids it in
the
first instance.

users = %w( admin Admin admiN ).each(|element| element.downcase! }
validates_exclusion_of :login, :in => users, :message => ‘is reserved
for
system accounts’