class NxtSchema::Validators::Includes

Attributes

target[R]

Public Class Methods

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

Public Instance Methods

build() click to toggle source
# File lib/nxt_schema/validators/includes.rb, line 11
def build
  lambda do |node, value|
    if value.include?(target)
      true
    else
      message = translate_error(coerced?.locale, value: value, target: target)
      node.add_error(message)
    end
  end
end