Sha256: 83447c46f6e5caea5684a6bd76e220ac296bc277af1c2f7ae7edfa1e5d3faa63

Contents?: true

Size: 443 Bytes

Versions: 23

Compression:

Stored size: 443 Bytes

Contents

module Riveter
  class BooleanessValidator < ActiveModel::EachValidator
    def validate_each(record, attribute, value)
      unless [true, false].include?(value)
        record.errors.add(attribute, :booleaness, :value => value)
      end
    end
  end
end

# add compatibility with ActiveModel validates method which
# matches option keys to their validator class
ActiveModel::Validations::BooleanessValidator = Riveter::BooleanessValidator

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
riveter-0.8.3 lib/riveter/booleaness_validator.rb
riveter-0.8.2 lib/riveter/booleaness_validator.rb
riveter-0.8.1 lib/riveter/booleaness_validator.rb
riveter-0.8.0 lib/riveter/booleaness_validator.rb
riveter-0.7.0 lib/riveter/booleaness_validator.rb
riveter-0.6.0 lib/riveter/booleaness_validator.rb
riveter-0.3.0 lib/riveter/booleaness_validator.rb
riveter-0.2.1 lib/riveter/booleaness_validator.rb
riveter-0.2.0 lib/riveter/booleaness_validator.rb
riveter-0.1.1 lib/riveter/booleaness_validator.rb
riveter-0.0.15 lib/riveter/booleaness_validator.rb
riveter-0.0.14 lib/riveter/booleaness_validator.rb
riveter-0.0.13 lib/riveter/booleaness_validator.rb
riveter-0.0.12 lib/riveter/booleaness_validator.rb
riveter-0.0.11 lib/riveter/booleaness_validator.rb
riveter-0.0.10 lib/riveter/booleaness_validator.rb
riveter-0.0.9 lib/riveter/booleaness_validator.rb
riveter-0.0.8 lib/riveter/booleaness_validator.rb
riveter-0.0.7 lib/riveter/booleaness_validator.rb
riveter-0.0.6 lib/riveter/booleaness_validator.rb