Sha256: def7f9d582a1dbf9d33944d3a491ef604ec532b422ab0a7b1cce22e1a27fb344

Contents?: true

Size: 475 Bytes

Versions: 3

Compression:

Stored size: 475 Bytes

Contents

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

      register_as :includes
      attr_reader :target

      def build
        lambda do |node, value|
          if value.include?(target)
            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/includes.rb
nxt_schema-0.1.1 lib/nxt_schema/validators/includes.rb
nxt_schema-0.1.0 lib/nxt_schema/validators/includes.rb