Created
January 17, 2013 16:38
-
-
Save raddrick/4557351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
field_type :optional_name_check do | |
field :self do | |
type :text_field, :minlength=>0 | |
end | |
validates :logic=>lambda{ |field| | |
if (get_value.length==1) || ((get_value.split(/(.)\1\1/).join != get_value) || (get_value.split(/[@#\$%&*_;:"+=.,<>?\\\}\{\^\(\)\]\[]/).join != get_value )) && (get_value.length >1) | |
errors.add(field_name, "Only alphabetic, not 3 consecutive identical, longer than 1 character.") | |
end | |
} , :allow_blank=>true | |
end | |
field_type :name_check do | |
field :self do | |
type :text_field | |
end | |
# validates_length :is => 2, :allow_blank => true | |
validates :logic=>lambda{ |field| | |
#if (get_value.split(/(.)\1\1/).join != get_value) || (get_value.to_s.length<2) || (get_value.split(/[@#\$%&*_;:"+=.,<>?\\\}\{\^\(\)\]\[]/).join != get_value ) | |
if (get_value.length==1) || ((get_value.split(/(.)\1\1/).join != get_value) || (get_value.split(/[@#\$%&*_;:"+=.,<>?\\\}\{\^\(\)\]\[]/).join != get_value )) && (get_value.length >1) | |
errors.add(field_name, "Only alphabetic, not 3 consecutive identical, longer than 1 character") | |
end | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment