Class: Spina::Admin::Conferences::FinishTimeValidator

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

Overview

Validator for times which should occur after a start_time.

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 (Time)

    the attribute value



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

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

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