Skip to content

Instantly share code, notes, and snippets.

@ryrych
Created July 27, 2015 04:08
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 ryrych/335d0a3e2f35841331b3 to your computer and use it in GitHub Desktop.
Save ryrych/335d0a3e2f35841331b3 to your computer and use it in GitHub Desktop.
formatting hashes in Ruby / Rails
class User < ActiveRecord::Base
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :name, presence: true, length: { maximum: 50 }
validates :email, presence: true, length: { maximum: 25 },
format: { with: VALID_EMAIL_REGEX }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment