On 27 Aug 2015, at 02:08, Henrik Lindberg <henrik.lindb...@cloudsmith.com> wrote:
> On 2015-26-08 17:56, Martin Alfke wrote: >> Hi Henrik, >> On 26 Aug 2015, at 17:49, Henrik Lindberg <henrik.lindb...@cloudsmith.com> >> wrote: >> > >> Hash[String, Struct[{ uid => Integer, home => Pattern[/^\/.*/]}]] $hash >> >> Am I missing something? >> Within the Struct I provide the key name (uid) and Type (Integer) and the >> second key (home) with Type (Pattern). >> > Yes, you are indeed. Your regular expression is however not correct for the > home directories that you have given. The regexp /^\/.*/ requires that the > string starts with a slash. If you change your input to say > > home => '/home/jones' > > it should work. Ah. It does work providing correct data. The error message if I do provide a string with missing / at start pointed me into wrong direction. Many thanks for your help. I know learned that using Struct inside has will not give a detailed output on a specific sub hash to be wrong. It complains about the whole hash being wrong without details. I am now heading for usage of keys function and check the elements of the sub hash inside a define. Best, Martin > > Or change the regular expression. The ^ means anchor at start of string, and > \/ means a slash is required, then 0 or more characters. If you accept any > String, simply use String. If you want to ensure that it is a valid path you > need a way more complex regular expression. > > Were you attempting to specify "not allowed to start with a slash"? > If so, try Pattern[/^[^\/]+.*/] > >>> >>>> Within class users I could use the keys function and a define and check >>>> for the data types within the define. >>>> But I thought that the mentioned approach is valid (at least I haven’t >>>> found a hint that my approach is not valid). >>>> >>> >>> Your approach is valid, you just got tripped up by Integer values not >>> matching with a Pattern. >> >> Good to know… >> > Sorry that I went of on a tangent after misreading the error message. > Hope the suggestions above will work out better for you. > > Regards > Henrik > > -- > > Visit my Blog "Puppet on the Edge" > http://puppet-on-the-edge.blogspot.se/ > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-dev+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-dev/mrlkee%244st%241%40ger.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 Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/F38C6FA2-79D5-4DAF-AB8D-C9B8CF1EFE3E%40gmail.com. For more options, visit https://groups.google.com/d/optout.