Checking the input value with a validate block

We can validate the provided value of a new property called version with a validate block and, for example, a regex expression, as shown in the following code:

Puppet::Type.newtype(:mynewtype) do
...
newproperty(:version) do
validate do |value|
fail("Invalid version specified") unless value =~
/^(d+.)?(d+.)?(*|d+)$/
end
end
...
end
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.253.152