If a field type validation is declared as follows:
the following error is seen when OIO calls the sub with a value of undef (aka the constructor is called with type => undef) ...sub validate_max_size { my $val = shift; ! defined $val || $val > 0; } . . # Then later ... . my @data :Field :Type( \&package::validate_max_size );
The problem is that no error unsues from running similar code as a one-liner e.g.# Failed test 'Valid max_size: undef' # at (eval 4) line 43. # died: OIO::Code error: Problem with type check routine for initializ +er 'max_size' for class 'IBM::Common::Collection # Error: Argument "undef" isn't numeric in numeric gt (>) # Package: main # File: t/IBM-Common-Collection.t # Line: 68
perl -Mstrict -we 'sub f {my $v = shift; ! defined $v || $v > 0}; f(un +def)'
Here's the rub: Has anybody else encountered (and hopefully, overcome) this problem ??
TIA ,
Update: Thanx, once again to ikegami who noticed a disparity between the use of or and ||. Having now tried all combinations of the 2 in the 2 circumstances, exasperatingly, the principle problem remains.
In reply to Object::InsideOut field type validation by Bloodnok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |