1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/app/validators/past_period_validator.rb
2023-03-22 10:58:22 +01:00

13 lines
338 B
Ruby

# frozen_string_literal: true
# Validates the current period is strictly in the past
class PastPeriodValidator < ActiveModel::Validator
def validate(record)
the_end = record.end_at
return if the_end.present? && the_end < Time.zone.today
record.errors.add(:end_at, I18n.t('errors.messages.must_be_in_the_past'))
end
end