class NxtSchema::Validators::Query
Attributes
method[R]
Public Class Methods
new(method)
click to toggle source
# File lib/nxt_schema/validators/query.rb, line 4 def initialize(method) @method = method end
Public Instance Methods
build()
click to toggle source
Query
a boolean method on you value => node(:test, :String).validate(:query, :good_enough?)
> Would be valid if value.good_enough? is truthy¶ ↑
# File lib/nxt_schema/validators/query.rb, line 14 def build lambda do |node, value| raise ArgumentError, "#{value} does not respond to query: #{method}" unless value.respond_to?(method) if value.send(method) true else message = translate_error(node.locale, value: value, actual: value.send(method), query: method) node.add_error(message) end end end