Another small change is the usage of the + operator on hashes instead of stdlib's merge().
There's probably more that can be done on them (any input or suggestions is welcomed) , but in particular I have a point I'd like to fix.
When Parameters are undef by default I didn't find anything better than enforcing an "Any" type, which actually does not validate anything:
definetp::conf4 (
String $ensure=present,
Any $source= undef,
Any $template= undef,
Any $epp= undef,
Any $content= undef,
is there a concise way (without other verbose conditionals in the code) to validate a parameter type IF that parameter is passed when is undef by default?
Any help appreciated,
al
Henrik Lindberg
unread,
Apr 12, 2015, 7:35:22 AM4/12/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Use the type Optional[T] to enforce either the type T, or undef. In your
example, say that $content must be a non empty string, or undef then you
could type it like this:
Optional[String[1]] $content = undef
Depending on what is accepted you can also use a Variant type with an
explicit Undef, this means the same thing as above: