Skip to content

Instantly share code, notes, and snippets.

@raddrick
Created January 17, 2013 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raddrick/4558245 to your computer and use it in GitHub Desktop.
Save raddrick/4558245 to your computer and use it in GitHub Desktop.
field_type :address_type_check do
field :self do
type :text_field, :size => 25, :maxlength => 25
end
validates :logic => lambda{|field|
errors.add(field_name, "Must have street names and numbers, and no groups of 3 consecutive letters. ") unless ((get_value.length>1) && (get_value.split(" ").count>1) && (get_value.split(/(\D)\1\1/).join == get_value) )
# (get_value.length>1)
# && (get_value.split(" ").count>2)
# && (get_value.split(/(.)\1\1/).join != get_value)
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment