Sha256: 7602b500e1aa312b3af03d96819d59a30c814cd22447b1f775b50e835ecf9d43
Contents?: true
Size: 570 Bytes
Versions: 17
Compression:
Stored size: 570 Bytes
Contents
module Datacaster class Comparator < Base def initialize(value, error_key = nil) @value = value @error_keys = ['.compare', 'datacaster.errors.compare'] @error_keys.unshift(error_key) if error_key end def cast(object, runtime:) if @value == object Datacaster.ValidResult(object) else Datacaster.ErrorResult( I18nValues::Key.new(@error_keys, reference: @value.inspect, value: object) ) end end def inspect "#<Datacaster::Comparator(#{@value.inspect})>" end end end
Version data entries
17 entries across 17 versions & 1 rubygems