1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/models/relationship_status.rb

29 lines
613 B
Ruby

# frozen_string_literal: true
class RelationshipStatus < ApplicationRecord
CODENAME_RE = /\A[a-z][a-z0-9]*(_[a-z0-9]+)*\z/.freeze
FORMAT_RE = /\A[^[:space:]]+(.*[^[:space:]]+)?\z/.freeze
###############
# Validations #
###############
validates :codename,
presence: true,
length: { in: 3..36 },
format: CODENAME_RE,
uniqueness: { case_sensitive: false }
validates :name,
presence: true,
length: { in: 1..255 },
format: FORMAT_RE
###########
# Methods #
###########
def to_param
codename
end
end