Subject: | Types::Standard: please add StrLen (string with length) type |
Date: | Tue, 22 Oct 2013 12:41:56 +0200 |
To: | bug-Type-Tiny [...] rt.cpan.org |
From: | BPJ <bpj [...] melroch.se> |
First off, thanks for a great distribution!
One thing I sorely miss in Types::Standard is a type for a string
with length -- at first I thought Str required length > 0 because
Params::Util::_STRING and Data::Util::is_string which I've used
before check for non-zero length, and got bitten. I'm hardly the
only one who needs to check for a non-zero-length string on a
regular basis, so I think a StrLen (string with length) type
would be in order, and ideally I'd not complain if it took
optional parameters for min and max length but defaulted to
length > 0; I guess one could achive this with
StrMatch[ qr{ \A .{1,} \z }msx ]
or the like, but with a less than intuitive error message I'm afraid.
TIA,
/bpj