class ValueSemantics::ArrayOf
Validator that matches arrays if each element matches a given subvalidator
Attributes
element_validator[R]
Public Class Methods
new(element_validator)
click to toggle source
# File lib/value_semantics/array_of.rb, line 8 def initialize(element_validator) @element_validator = element_validator freeze end
Public Instance Methods
===(value)
click to toggle source
@return [Boolean]
# File lib/value_semantics/array_of.rb, line 14 def ===(value) Array === value && value.all? { |element| element_validator === element } end