Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my %constraint =
- # Prompter Add to What to print on Use this to check that Conversion
- # type prompt invalid input input is valid function
- # ======== ====== ================ ====================== ==========
- ::Int => [': ', 'a valid integer', /^ \h* <integer> \h* $/, *.Int ],
- ::Num => [': ', 'a valid number', /^ \h* <number> \h* $/, +* ],
- ::Bool => ['? ', '"yes" or "no"', /^ \h* <yesno> \h* $/, {?/<yes>/} ],
- SemiBool => ['? ', '"yes" or "no"', /^ \h* \S+ \h* $/, {?/<yes>/} ],
- CapSemiBool => ['? ', '"Yes" for yes', /^ \h* <Yes> \h* $/, {?/<yes>/} ],
- CapFullBool => ['? ', '"Yes" or "No"', /^ \h* <YesNo> \h* $/, {?/<yes>/} ],
- Any => [': ', 'anything', / <null> /, { $^self } ];
- my ($punct, $description, $match, $extractor)
- = %constraint{$type} // %constraint<Any>;
- # does not work in current Rakudo: the entire Array in %constraint{$type} is assigned to $punct,
- # while the remainder of $description, etc get Any().
Add Comment
Please, Sign In to add comment