Sha256: f0b9d9a4bc0f7ddf523024417ee0b07b2ab4d9a762473e8293bf960ffec1017a

Contents?: true

Size: 475 Bytes

Versions: 3

Compression:

Stored size: 475 Bytes

Contents

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

      register_as :excluded
      attr_reader :target

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

Version data entries

3 entries across 3 versions & 1 rubygems

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