Puppet Function: validate_array_re

Defined in:
modules/wmflib/lib/puppet/parser/functions/validate_array_re.rb
Function type:
Ruby 3.x API

Overview

validate_array_re()Any

Returns:

  • (Any)


15
16
17
18
19
20
21
22
# File 'modules/wmflib/lib/puppet/parser/functions/validate_array_re.rb', line 15

newfunction(:validate_array_re, :arity => 2) do |args|
  items, re = args
  re = Regexp.new(re)
  invalid = items.find { |item| item.to_s !~ re }
  unless invalid.nil?
    fail(Puppet::ParseError, "Array element \"#{invalid}\" does not match regular expression \"#{re.source}\".")
  end
end