Puppet Function: validate_in_range
- Defined in:
-
lib/puppet/parser/functions/validate_in_range.rb
- Function type:
- Ruby 3.x API
Summary
Validate the incoming value is in a certain range.
Overview
validate_in_range() ⇒ Any
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/puppet/parser/functions/validate_in_range.rb', line 6
newfunction(:validate_in_range, doc: <<-EOS
@summary
Validate the incoming value is in a certain range.
@return
Raises an error if the given value fails this validation.
EOS
) do |args|
data, min, max = *args
data = Integer(data)
min = Integer(min)
max = Integer(max)
if data < min
raise("Expected #{data} to be greater or equal to #{min}, got #{data}")
end
if data > max
raise("Expected #{data} to be less or equal to #{min}, got #{data}")
end
end
|