Sha256: be2fc08cf48c5b740c8a9a6b582e1bcb6c72322efbdac2f152c83f3abff04f86

Contents?: true

Size: 414 Bytes

Versions: 10

Compression:

Stored size: 414 Bytes

Contents

require 'hermod/validators/base'

module Hermod
  module Validators
    # Checks a decimal value has no decimal componant, i.e. it's just a decimal
    # representation of an integer
    class WholeUnits < Base

      private

      def test(value, attributes)
        value.blank? || value == value.to_i
      end

      def message(value, attributes)
        "must be in whole units"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hermod-3.3.0 lib/hermod/validators/whole_units.rb
hermod-3.2.0 lib/hermod/validators/whole_units.rb
hermod-3.0.0 lib/hermod/validators/whole_units.rb
hermod-2.7.0 lib/hermod/validators/whole_units.rb
hermod-2.7.0.pre.rc.1 lib/hermod/validators/whole_units.rb
hermod-2.6.2 lib/hermod/validators/whole_units.rb
hermod-2.6.1 lib/hermod/validators/whole_units.rb
hermod-2.5.3 lib/hermod/validators/whole_units.rb
hermod-2.5.2 lib/hermod/validators/whole_units.rb
hermod-2.5.1 lib/hermod/validators/whole_units.rb