Sha256: dd5d08a9f288e68f5ff6aea70ee0a31115ee75ad27f67eaeff843ff7a479cff8

Contents?: true

Size: 518 Bytes

Versions: 4

Compression:

Stored size: 518 Bytes

Contents

module NxtSchema
  module Validators
    class LessThanOrEqual < Validator
      def initialize(threshold)
        @threshold = threshold
      end

      register_as :less_than_or_equal, :lt_or_eql
      attr_reader :threshold

      def build
        lambda do |node, value|
          if value <= threshold
            true
          else
            message = translate_error(node.locale, value: value, threshold: threshold)
            node.add_error(message)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nxt_schema-1.0.2 lib/nxt_schema/validators/less_than_or_equal.rb
nxt_schema-0.1.2 lib/nxt_schema/validators/less_than_or_equal.rb
nxt_schema-0.1.1 lib/nxt_schema/validators/less_than_or_equal.rb
nxt_schema-0.1.0 lib/nxt_schema/validators/less_than_or_equal.rb