summaryrefslogtreecommitdiff
path: root/app/models/user_account.rb
blob: e50961b9b62976249e6a0b0992670246d43ebfe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

# UserAccount model
# email: string
# password_digest (secure password): string
# first_name: string
# last_name: string
# session_key: string
class UserAccount < ApplicationRecord
  has_secure_password validations: false
  validates :email, presence: true
  validates :password, presence: true
  validates_format_of :email,
                      with: /\A(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})\z/i
  validates :first_name, presence: true
  validates :last_name, presence: true
  validates :role, presence: true, inclusion: { in: %w[master regular] }

  def full_name
    "#{first_name} #{last_name}"
  end
end