1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-05 16:24:21 +01:00
fab-manager/app/validators/past_period_validator.rb
2019-04-03 17:27:25 +02:00

13 lines
331 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 < Date.today
record.errors[:end_at] << I18n.t('errors.messages.must_be_in_the_past')
end
end