Class: Spina::Admin::Conferences::FinishDateValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/spina/admin/conferences/finish_date_validator.rb

Overview

Validator for dates which should occur after a start_date.

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object

Performs validation on the supplied record.

Parameters:

  • record (ActiveRecord::Base)

    the associated record

  • attribute (Symbol)

    the attribute key

  • value (Date)

    the attribute value



12
13
14
15
16
# File 'app/validators/spina/admin/conferences/finish_date_validator.rb', line 12

def validate_each(record, attribute, value)
  return if value.blank? || record.start_date.blank? || value >= record.start_date

  record.errors.add(attribute, :before_start_date)
end