Sha256: 72d1150e37fa962dc48b0536c141f0b973cf439631266933d73a44d2a77cd446

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'data_mapper/validation/rule/numericalness'

module DataMapper
  module Validation
    class Rule
      module Numericalness

        class LessThanOrEqual < Rule

          include Numericalness

          def valid_numericalness?(value)
            value <= expected
          rescue ArgumentError
            # TODO: figure out better solution for: can't compare String with Integer
            true
          end

          def violation_type(resource)
            :less_than_or_equal_to
          end

          def violation_data(resource)
            [ [ :maximum, expected ] ]
          end

        end # class LessThanOrEqual

      end # module Numericalness
    end # class Rule
  end # module Validation
end # module DataMapper

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sbf-dm-validations-1.4.0 lib/data_mapper/validation/rule/numericalness/less_than_or_equal.rb
sbf-dm-validations-1.3.0 lib/data_mapper/validation/rule/numericalness/less_than_or_equal.rb
sbf-dm-validations-1.3.0.beta lib/data_mapper/validation/rule/numericalness/less_than_or_equal.rb