First off, you should use data types with your class and then you won't
have to check--the compile won't even succeed unless you've got the right
data type.

class foo (
    Integer $subsetting,
) {
    # $subsetting is guaranteed to be numeric here
    ....
}

Second, you can use the is_a
<https://forge.puppet.com/puppetlabs/stdlib#is_a> function, or the ~=
equality matcher.



On Mon, Aug 6, 2018 at 8:28 AM Helmut Schneider <jumpe...@gmx.de> wrote:

> Hi,
>
> I want to check if a variable is numeric. The manpage says is_numeric
> is deprectaed and I shall user validate_legacy. But
>
> <% if validate_legacy(Numeric, 'validate_numeric', $subsetting) { -%>
>
> Error: Could not retrieve catalog from remote server: Error 500 on
> SERVER: Server Error: Evaluation Error: Error while evaluating a
> Function Call, validate_legacy(validate_numeric) expects a Numeric
> value, got String at
> /etc/puppetlabs/code/modules/bacula/templates/etc/bacula/bacula-dir.conf
> .epp:25:7 on node bsdhelmut1164
>
> What is the proper way to check if something is numeric?
>
> Thank you!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/xn0lddxg1g5gp4001%40news.gmane.org
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CACkW_L6GCpzAVt-74-mE%2BXmrLu49_Y8XxOVW4CuXLaDYkxpNsA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to