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

35 lines
759 B
Ruby
Raw Normal View History

2018-12-02 09:16:16 -05:00
# frozen_string_literal: true
class PassportMap < ApplicationRecord
enum sex: %i[male female]
2019-03-25 20:56:31 -04:00
################
# Associations #
################
2018-12-02 09:16:16 -05:00
belongs_to :passport
2019-03-25 20:56:31 -04:00
###############
# Validations #
###############
2019-03-26 16:18:21 -04:00
validates :first_name, presence: true
validates :last_name, presence: true
2018-12-02 09:16:16 -05:00
validates :sex, presence: true
validates :date_of_birth, presence: true
validates :place_of_birth, presence: true
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-03-25 20:56:31 -04:00
#############
# Callbacks #
#############
2018-12-02 09:16:16 -05:00
before_validation do
2019-03-26 16:18:21 -04:00
self.middle_name = nil if middle_name.blank?
2018-12-02 09:16:16 -05:00
end
end