Time again to prostrate myself before you highly-esteemed fellow monks concerning a problem I've encountered with Object::InsideOut ... and more specifically, the type validation of fields therein.

If a field type validation is declared as follows:

sub validate_max_size { my $val = shift; ! defined $val || $val > 0; } . . # Then later ... . my @data :Field :Type( \&package::validate_max_size );
the following error is seen when OIO calls the sub with a value of undef (aka the constructor is called with type => undef) ...
# 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
The problem is that no error unsues from running similar code as a one-liner e.g.
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.

A user level that continues to overstate my experience :-))

In reply to Object::InsideOut field type validation by Bloodnok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.