This queue is for tickets about the Data-Validate-Struct CPAN distribution.

Report information
The Basics
Id:
101884
Status:
resolved
Priority:
Low/Low

People
Owner:
Nobody in particular
Requestors:
mathieu.bivert [...] gmail.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)



CC: tlinden@cpan.org
Subject: bugs and questions on Data::Validate::Struct
Date: Mon, 2 Feb 2015 19:02:17 +0100
To: bug-Data-Validate-Struct@rt.cpan.org
From: Mathieu Bivert <mathieu.bivert@gmail.com>
Hi,

1/ In Struct.pm:/^sub _trim, the substitution is missing a g flag.
Here's a snippet:

(saturn); perl -e '$_=" hello "; print "X${_}X\n"'
X hello X
(saturn); perl -e '$_=" hello "; s/^\s+|\s+$//; print "X${_}X\n"'
Xhello X
(saturn); perl -e '$_=" hello "; s/^\s+|\s+$//g; print "X${_}X\n"'                                                                                        
XhelloX

2/ optional seems in-effective if the value of the key is undef  (see attached t.pl)

3/ In case an item has a value undef, 'undefined value …' is triggered.

4/ Please, find attached (t.patch) a sample diff(1) attached as workaround on the problems
listed above.

The attached t.pl file should trigger them all.

5/ is there any plan to have optional array or hash?
or alternatively, is there any available hack around it ?

The only solution that comes to my mind is to associate to each possible
node a hash { types = @types, value = $reference_value }.

But this is less handy to use, and requires changing the API :-)

Thanks for your work and have a nice day,

Mathieu

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Fixed in 0.10. Thanks for reporting! - Tom


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.