# Emulate the is_hash and validate_hash functions
type Stdlib::Compat::Hash = Hash[Any, Any]
# Emulate the is_integer and validate_integer functions
# The regex is what's currently used in is_integer
# validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function.
# For full backwards compatibility, you will need to keep the validate_numeric call around to catch everything.
# To keep your development moving forward, you can also add a deprecation warning using the Integer type:
#
# ```class example($value) { validate_integer($value, 10, 0) }```
#
# would turn into
#
# ```
# class example(Stdlib::Compat::Integer $value) {
# validate_numeric($value, 10, 0)
# assert_type(Integer[0, 10], $value) |$expected, $actual| {
# warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.")
# }
# }
# ```
#
# > Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers.
#
# This allows you to find all places where a consumers of your code call it with unexpected values.
type Stdlib::Compat::Integer = Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]] # lint:ignore:140chars
type Stdlib::Compat::Ip_address = Variant[Stdlib::Compat::Ipv4, Stdlib::Compat::Ipv6]
# Emulate the validate_ipv4_address and is_ipv4_address functions
type Stdlib::Compat::Ipv4 = Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/] # lint:ignore:140chars
type Stdlib::Compat::Ipv6 = Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/] # lint:ignore:140chars
# Emulate the is_numeric and validate_numeric functions
# The regex is what's currently used in is_numeric
# validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function.
# For full backwards compatibility, you will need to keep the validate_numeric call around to catch everything.
# To keep your development moving forward, you can also add a deprecation warning using the Integer type:
#
# ```class example($value) { validate_numeric($value, 10, 0) }```
#
# would turn into
#
# ```
# class example(Stdlib::Compat::Numeric $value) {
# validate_numeric($value, 10, 0)
# assert_type(Integer[0, 10], $value) |$expected, $actual| {
# warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.")
# }
# }
# ```
#
# > Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers.
#
# This allows you to find all places where a consumers of your code call it with unexpected values.
type Stdlib::Compat::Numeric = Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]] # lint:ignore:140chars
# Emulate the validate_re function
# validate_re(value, re) translates to Pattern[re], which is not directly mappable as a type alias, but can be specified as Pattern[re].
# Therefore this needs to be translated directly.
# Emulate the is_string and validate_string functions
type Stdlib::Compat::String = Optional[String]
type Stdlib::Datasize = Pattern[/^\d+(?i:[kmgt]b?|b)$/]
# https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
type Stdlib::Email = Pattern[/\A[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/]
type Stdlib::Ensure::File = Enum['present', 'file', 'directory', 'link', 'absent']
type Stdlib::Ensure::File::Directory = Enum['directory', 'absent']
type Stdlib::Ensure::File::File = Enum['file', 'absent']
type Stdlib::Ensure::File::Link = Enum['link', 'absent']
type Stdlib::Ensure::Service = Enum['stopped', 'running']
# See `man chmod.1` for the regular expression for symbolic mode
# lint:ignore:140chars
type Stdlib::Filemode = Pattern[/\A(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))\z/]
# lint:endignore
# Validate the source parameter on file types
type Stdlib::Filesource = Variant[
Stdlib::Absolutepath,
Stdlib::HTTPUrl,
Pattern[
/\Afile:\/\/\/([^\n\/\0]+(\/)?)+\z/,
/\Apuppet:\/\/(([\w-]+\.?)+)?\/([^\n\/\0]+(\/)?)+\z/,
],
]
type Stdlib::Fqdn = Pattern[/\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/]
type Stdlib::Host = Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address]
type Stdlib::HttpStatus = Integer[100, 599]