Sha256: 23ea5521a19689cd4752b7557bd7ffd74d3403b4262d415674acb5dd52a2464c

Contents?: true

Size: 475 Bytes

Versions: 4

Compression:

Stored size: 475 Bytes

Contents

module NxtSchema
  module Validators
    class Excludes < Validator
      def initialize(target)
        @target = target
      end

      register_as :excludes
      attr_reader :target

      def build
        lambda do |node, value|
          if value.exclude?(target)
            true
          else
            message = translate_error(node.locale, target: target, value: value)
            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/excludes.rb
nxt_schema-0.1.2 lib/nxt_schema/validators/excludes.rb
nxt_schema-0.1.1 lib/nxt_schema/validators/excludes.rb
nxt_schema-0.1.0 lib/nxt_schema/validators/excludes.rb