Sha256: 88cdae8c4f2165d2b51b02d20206299c5669418e5267ae753cfb614e5f51dd72

Contents?: true

Size: 495 Bytes

Versions: 4

Compression:

Stored size: 495 Bytes

Contents

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

      register_as :greater_than
      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/greater_than.rb
nxt_schema-0.1.2 lib/nxt_schema/validators/greater_than.rb
nxt_schema-0.1.1 lib/nxt_schema/validators/greater_than.rb
nxt_schema-0.1.0 lib/nxt_schema/validators/greater_than.rb