hoppfrosch has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I want to use Moose type constraints for an attribute which could either be undefined or - if the attribute is provided on new() - match a given RegEx.
What I currently have is:
has 'attr' => ( is => 'ro', isa => subtype( as 'Str', where { /$regEx/ } ), required => 0 );
I cannot figure out, where to put the undef to - or I have an incorrect syntax. Any hint welcome ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moose Attribute constraint: Regex OR undef
by 1nickt (Canon) on Oct 31, 2016 at 12:57 UTC | |
by hoppfrosch (Scribe) on Nov 01, 2016 at 09:26 UTC | |
|
Re: Moose Attribute constraint: Regex OR undef
by Corion (Patriarch) on Oct 31, 2016 at 12:19 UTC |