# frozen_string_literal: true module C class Enquiry < ApplicationRecord validates :name, presence: true scope :ordered, -> { order created_at: :desc } VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX } INDEX_TABLE = { "Name": { call: 'name', sort: 'name' }, "Email": { call: 'email', sort: 'email' }, "Message": { call: 'body' }, "Date": { call: 'created_at', sort: 'created_at' } }.freeze end end