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/contact_network.rb

36 lines
689 B
Ruby
Raw Normal View History

2019-08-04 17:05:57 -04:00
# frozen_string_literal: true
class ContactNetwork < ApplicationRecord
CODENAME_RE = /\A[a-z][a-z0-9]*(_[a-z0-9]+)*\z/.freeze
2019-08-18 01:15:03 -04:00
FORMAT_RE = /\A[^[:space:]]+(.*[^[:space:]]+)?\z/.freeze
2019-08-04 17:05:57 -04:00
################
# Associations #
################
2019-08-17 22:12:13 -04:00
has_many :contacts
2019-08-04 17:05:57 -04:00
###############
# Validations #
###############
validates :codename,
2019-08-04 17:05:57 -04:00
presence: true,
length: { in: 3..36 },
format: CODENAME_RE,
2019-08-04 17:05:57 -04:00
uniqueness: { case_sensitive: false }
2019-08-18 01:15:03 -04:00
validates :name,
presence: true,
length: { in: 1..255 },
format: FORMAT_RE
2019-08-04 17:05:57 -04:00
2019-08-17 20:03:18 -04:00
###########
# Methods #
###########
def to_param
codename
end
2019-08-04 17:05:57 -04:00
end