Sha256: 7d75b8c0129aa69b06bd7449aad24f6255fdd49fd48d4d66333a6e9c89a944b2

Contents?: true

Size: 475 Bytes

Versions: 3

Compression:

Stored size: 475 Bytes

Contents

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

      register_as :included
      attr_reader :target

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