obdev/app/models/concerns/access_control_validations.rb

15 lines
437 B
Ruby

module AccessControlValidations
extend ActiveSupport::Concern
included do
validate :end_date_after_start_date, if: -> { access_revoked && access_end_date.present? }
end
private
def end_date_after_start_date
if access_start_date.present? && access_end_date.present? && access_end_date < access_start_date
errors.add(:access_end_date, 'must be after the start date')
end
end
end