2018-11-29 20:19:38 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Passport < ApplicationRecord
|
2019-07-25 17:15:40 -04:00
|
|
|
include RequiredNameable
|
2019-07-18 14:44:46 -04:00
|
|
|
|
2019-07-22 09:52:23 -04:00
|
|
|
FORMAT_RE = /\A[^[:space:]]+(.*[^[:space:]]+)?\z/.freeze
|
|
|
|
|
2019-03-25 20:56:31 -04:00
|
|
|
################
|
|
|
|
# Associations #
|
|
|
|
################
|
|
|
|
|
2019-01-30 22:04:42 -05:00
|
|
|
belongs_to :person, optional: true
|
2019-07-22 09:52:23 -04:00
|
|
|
belongs_to :federal_subject, optional: true
|
2019-01-30 22:04:42 -05:00
|
|
|
|
2019-07-18 14:44:46 -04:00
|
|
|
###############
|
|
|
|
# Validations #
|
|
|
|
###############
|
2018-12-02 17:20:16 -05:00
|
|
|
|
2019-07-18 14:44:46 -04:00
|
|
|
validates :series, presence: true
|
|
|
|
validates :number, presence: true
|
|
|
|
validates :issued_by, presence: true
|
|
|
|
validates :unit_code, presence: true
|
|
|
|
validates :date_of_issue, presence: true
|
2019-07-22 09:52:23 -04:00
|
|
|
|
|
|
|
validates :zip_code,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :town_type,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :town_name,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :settlement_type,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :settlement_name,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :district_type,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :district_name,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :street_type,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :street_name,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :residence_type,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :residence_name,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :building_type,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :building_name,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :apartment_type,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
|
|
|
|
|
|
|
validates :apartment_name,
|
|
|
|
allow_nil: true,
|
|
|
|
length: { in: 1..255 },
|
|
|
|
format: { with: FORMAT_RE }
|
2018-11-29 20:19:38 -05:00
|
|
|
end
|