Sha256: 6fff316b5425c05d3bd54e6de8aa3aa1f5ae76054f2bd7f79579cd891bc46f15

Contents?: true

Size: 499 Bytes

Versions: 2

Compression:

Stored size: 499 Bytes

Contents

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

      register_as :excluded_in
      attr_reader :target

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nxt_schema-1.0.1 lib/nxt_schema/validators/excluded_in.rb
nxt_schema-1.0.0 lib/nxt_schema/validators/excluded_in.rb