class NxtSchema::Validators::LessThan

Attributes

threshold[R]

Public Class Methods

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

Public Instance Methods

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