# frozen_string_literal: true module Dhall module Util class ArrayOf < ValueSemantics::ArrayOf def initialize(element_validator, min: 0, max: Float::INFINITY) @min = min @max = max super(element_validator) end def ===(other) super && other.length >= @min && other.length <= @max end end class HashOf def initialize(element_validator, min: 0, max: Float::INFINITY) @min = min @max = max @element_validator = element_validator end def ===(other) Hash === other && other.values.all? { |x| @element_validator === x } && other.size >= @min && other.size <= @max end end end end