Skip to content

Instantly share code, notes, and snippets.

@Znow
Created June 6, 2011 17:18
Show Gist options
  • Select an option

  • Save Znow/1010659 to your computer and use it in GitHub Desktop.

Select an option

Save Znow/1010659 to your computer and use it in GitHub Desktop.
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i # full regex
validates :name, :length => { :maximum => 50 },
:presence => true # a validation of :name has to be present and a max character length of 50
validates :email, :format => { :with => email_regex },
:uniqueness => { :case_sensitive => false }, # email has to be unique, and it does not effect if case
:presence => true
validates :password, :presence => true,
:on => :create,
:confirmation => true, # it needs a confirmation
:length => { :within => 6..40 } # the length has to be WITHIN 6-40 characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment