Puppet Function: validate_umask

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

Overview

validate_umask()Nil

Validate that the passed String is a valid umask

Examples:

$val = '0077'
validate_umask($val) => OK

$val = '0078'
validate_umask($val) => BAD

Returns:

  • (Nil)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppet/parser/functions/validate_umask.rb', line 2

newfunction(:validate_umask, :doc => <<-'ENDHEREDOC') do |args|

  unless Array(args).length == 1
  Validate that the passed `String` is a valid `umask`

  @example
    $val = '0077'
    validate_umask($val) => OK

    $val = '0078'
    validate_umask($val) => BAD

  @return [Nil]
  ENDHEREDOC
    raise Puppet::ParseError, ("validate_umask() takes exactly one argument")
  end

  unless Array(args).first =~ /^[0-7]{3,4}$/
    raise Puppet::ParseError, ("'#{args}' is not a valid umask.")
  end
end