Sha256: e304777fb26fe9d342f6b502d43659b43c597f0d089281e1cbcd61e4d140eaeb

Contents?: true

Size: 367 Bytes

Versions: 28

Compression:

Stored size: 367 Bytes

Contents

module Validatable
  class ValidatesAcceptanceOf < ValidationBase #:nodoc:    
    def valid?(instance)
      value = instance.send(self.attribute)
      return true if allow_nil && value.nil?
      return true if allow_blank && value.blank?
      %w(1 true t).include?(value)
    end
    
    def message(instance)
      super || "must be accepted"
    end
  end
end

Version data entries

28 entries across 28 versions & 7 rubygems

Version Path
hashrocket-validatable-1.7.2 lib/validations/validates_acceptance_of.rb
hashrocket-validatable-1.7.4 lib/validations/validates_acceptance_of.rb
jnunemaker-validatable-1.7.0 lib/validations/validates_acceptance_of.rb
jnunemaker-validatable-1.7.1 lib/validations/validates_acceptance_of.rb
jnunemaker-validatable-1.7.2 lib/validations/validates_acceptance_of.rb
vizjerai-validatable-1.8.0 lib/validations/validates_acceptance_of.rb
vizjerai-validatable-1.9.0 lib/validations/validates_acceptance_of.rb
lgustafson-validatable-1.8.7 lib/validatable/validations/validates_acceptance_of.rb
lgustafson-validatable-1.8.6 lib/validatable/validations/validates_acceptance_of.rb
np422-validatable-1.8.5 lib/validatable/validations/validates_acceptance_of.rb
mattmatt-validatable-1.8.3 lib/validatable/validations/validates_acceptance_of.rb
jnunemaker-validatable-1.8.4 lib/validatable/validations/validates_acceptance_of.rb
jnunemaker-validatable-1.8.3 lib/validatable/validations/validates_acceptance_of.rb
jnunemaker-validatable-1.8.2 lib/validatable/validations/validates_acceptance_of.rb
jnunemaker-validatable-1.1.10 lib/validatable/validations/validates_acceptance_of.rb
jnunemaker-validatable-1.1.9 lib/validatable/validations/validates_acceptance_of.rb
durran-validatable-2.0.1 lib/validations/validates_acceptance_of.rb
durran-validatable-2.0.0 lib/validations/validates_acceptance_of.rb
durran-validatable-1.8.4 lib/validations/validates_acceptance_of.rb
durran-validatable-1.8.3 lib/validations/validates_acceptance_of.rb