Sha256: cb378b46ad2ce7574b4bb8967221172628b71468e8100abfbcff514f6b7051fa
Contents?: true
Size: 682 Bytes
Versions: 2
Compression:
Stored size: 682 Bytes
Contents
module Rasti module Types class Array include Castable attr_reader :type def self.[](type) new type end def to_s "#{self.class}[#{type}]" end alias_method :inspect, :to_s private def initialize(type) @type = type end def valid?(value) value.is_a? ::Array end def transform(value) MultiCaster.cast!(self, value) do |multi_caster| value.map.with_index do |e,i| multi_caster.cast type: type, value: e, error_key: i+1 end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rasti-types-2.0.1 | lib/rasti/types/array.rb |
rasti-types-2.0.0 | lib/rasti/types/array.rb |