Sha256: 6f25f1cb1ffeb4629336da2a918206ce5638ba31ea9233189df00ff6dc15982a

Contents?: true

Size: 542 Bytes

Versions: 66

Compression:

Stored size: 542 Bytes

Contents

module Hydra
  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[attribute] << "Must be a future date"
            end
          else
            record.errors[attribute] << "Invalid Date Format"
          end
        rescue ArgumentError, NoMethodError
          record.errors[attribute] << "Invalid Date Format"
        end
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
hydra-access-controls-12.0.2 app/validators/hydra/future_date_validator.rb
hydra-access-controls-11.0.7 app/validators/hydra/future_date_validator.rb
hydra-access-controls-12.0.1 app/validators/hydra/future_date_validator.rb
hydra-access-controls-11.0.6 app/validators/hydra/future_date_validator.rb
hydra-access-controls-12.0.0 app/validators/hydra/future_date_validator.rb
hydra-access-controls-11.0.1 app/validators/hydra/future_date_validator.rb
hydra-access-controls-11.0.0 app/validators/hydra/future_date_validator.rb
hydra-access-controls-11.0.0.rc2 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.7.0 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.6.2 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.6.1 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.6.0 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.5.1 app/validators/hydra/future_date_validator.rb
hydra-access-controls-11.0.0.rc1 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.5.0 app/validators/hydra/future_date_validator.rb
hydra-access-controls-8.2.0 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.4.0 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.4.0.rc2 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.4.0.rc1 app/validators/hydra/future_date_validator.rb
hydra-access-controls-10.3.4 app/validators/hydra/future_date_validator.rb