class User < ActiveRecord::Base
  has_many :carts
  
  validates_presence_of :first_name, :last_name, :password, :email, :password_confirmation

  validates :email, :uniqueness => {:case_sensitive => false, :message => "Email already exists!"},
    format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, message: "invalid email" }

  validates :password, confirmation: true, length: { in:6..20, too_short: 'password needs to be at least 6 characters long' }
end
