Sha256: 09c9e2b192d949a13f1fcec542b9412d20decbecc482bb8eb348ac04b15c0192

Contents?: true

Size: 337 Bytes

Versions: 107

Compression:

Stored size: 337 Bytes

Contents

class BirthdayValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if options[:allow_nil] && value.presence.nil?
    record.errors.add(attribute, :in_past) if !value || value >= Time.now.to_date
    record.errors.add(attribute, :after_1920) if !value || value <= Date.new(1920, 1, 1)
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
egov_utils-1.5.0.alpha15 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha14 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha13 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha12 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha11 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha10 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha9 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha8 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha7 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha6 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha5 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha4 app/validators/birthday_validator.rb
egov_utils-1.4.5 app/validators/birthday_validator.rb
egov_utils-1.4.4 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha3 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha2 app/validators/birthday_validator.rb
egov_utils-1.5.0.alpha1 app/validators/birthday_validator.rb
egov_utils-1.4.3 app/validators/birthday_validator.rb
egov_utils-1.4.2 app/validators/birthday_validator.rb
egov_utils-1.4.1 app/validators/birthday_validator.rb