-
Notifications
You must be signed in to change notification settings - Fork 580
/
validate_domain_name.rb
28 lines (26 loc) · 1.04 KB
/
validate_domain_name.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true
# @summary
# Validate that all values passed are syntactically correct domain names.
# Fail compilation if any value fails this check.
Puppet::Functions.create_function(:validate_domain_name) do
# @param values A domain name or an array of domain names to check
#
# @return
# passes when the given values are syntactically correct domain names or raise an error when they are not and fails compilation
#
# @example Passing examples
# $my_domain_name = 'server.domain.tld'
# validate_domain_name($my_domain_name)
# validate_domain_name('domain.tld', 'puppet.com', $my_domain_name)
#
# @exapmle Failing examples (causing compilation to abort)
# validate_domain_name(1)
# validate_domain_name(true)
# validate_domain_name('invalid domain')
# validate_domain_name('-foo.example.com')
# validate_domain_name('www.example.2com')
dispatch :validate_domain_name do
repeated_param 'Variant[Stdlib::Fqdn, Stdlib::Dns_zone]', :values
end
def validate_domain_name(*_values); end
end