Sha256: 1331224be3919c1dc344b8b7e6cf0a59dd1ebc72de9a992ccf44483aefb10708
Contents?: true
Size: 808 Bytes
Versions: 3
Compression:
Stored size: 808 Bytes
Contents
module NxtSchema module Validators class Equality < Validator def initialize(expectation) @expectation = expectation end register_as :equality, :eql attr_reader :expectation # Query for equality validator(:equality, 3) # Query for equality validator(:eql, -> { 3 * 3 * 60 }) def build lambda do |node, value| expected_value = expectation.respond_to?(:call) ? Callable.new(expectation).call(node, value) : expectation if value == expected_value true else node.add_error( translate_error( node.locale, actual: value, expected: expected_value ) ) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nxt_schema-0.1.2 | lib/nxt_schema/validators/equality.rb |
nxt_schema-0.1.1 | lib/nxt_schema/validators/equality.rb |
nxt_schema-0.1.0 | lib/nxt_schema/validators/equality.rb |