Class: Spina::Admin::Conferences::ConferenceDateValidator

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

Overview

Validator for dates which should occur during the associated conference.

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/conference_date_validator.rb', line 12

def validate_each(record, attribute, value)
  return if value.blank? || record.conference&.dates&.cover?(value.to_date)

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