Skip to content

Instantly share code, notes, and snippets.

@lesniakania
Last active August 29, 2015 14:15
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 lesniakania/6547cc3b1cbeed9ae16f to your computer and use it in GitHub Desktop.
Save lesniakania/6547cc3b1cbeed9ae16f to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
validates :username, :password, :email, :phone, :age, presence: true
validates :username,
length: { within: 5..20 },
uniqueness: true,
format: { with: /\A\w*\z/ }
validates :password, length: { within: 5..20 }
validates :email, format: { with: /.+@.+\..+/i }
validates :phone, format: { with: /\A\+48/ }
validates :age, numericality: true
# lots of other stuff that usually is here
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment