Sha256: 440b9d0bc841178e2187a25467f50e8492df9e752abe0ae65b7c00765306f23b

Contents?: true

Size: 528 Bytes

Versions: 13

Compression:

Stored size: 528 Bytes

Contents

class FutureDateValidator < ActiveModel::EachValidator

  def validate_each(record, attribute, value)
    if value.present?
      begin
        if date = value.to_date
          if date <= Date.today
            record.errors[:embargo_release_date] << "Must be a future date"
          end
        else
          record.errors[:embargo_release_date] << "Invalid Date Format"
        end
      rescue ArgumentError, NoMethodError
        record.errors[:embargo_release_date] << "Invalid Date Format"
      end
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
curate-0.6.6 app/validators/future_date_validator.rb
curate-0.6.5 app/validators/future_date_validator.rb
curate-0.6.4 app/validators/future_date_validator.rb
curate-0.6.3 app/validators/future_date_validator.rb
curate-0.6.1 app/validators/future_date_validator.rb
curate-0.6.0 app/validators/future_date_validator.rb
curate-0.5.6 app/validators/future_date_validator.rb
curate-0.5.5 app/validators/future_date_validator.rb
curate-0.5.4 app/validators/future_date_validator.rb
curate-0.5.2 app/validators/future_date_validator.rb
curate-0.5.1 app/validators/future_date_validator.rb
curate-0.5.0 app/validators/future_date_validator.rb
curate-0.4.2 app/validators/future_date_validator.rb