class NxtSchema::Validators::Excludes

Attributes

target[R]

Public Class Methods

new(target) click to toggle source
# File lib/nxt_schema/validators/excludes.rb, line 4
def initialize(target)
  @target = target
end

Public Instance Methods

build() click to toggle source
# File lib/nxt_schema/validators/excludes.rb, line 11
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