Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Moose throwing error with some data which doesn't match the 'Object' constraint, what should I do?

by LittleJack (Beadle)
on Jan 18, 2022 at 05:04 UTC ( [id://11140548]=perlquestion: print w/replies, xml ) Need Help??

LittleJack has asked for the wisdom of the Perl Monks concerning the following question:

I don't have a ton of experience with Moose. Say I've got a sub/method called 'foo'. Up at the top of the relevant module is this:

validate_subs ( foo => { params => { user => [Object, 1], bar=> [Str, 1], baz=> [Str, 1], } },

and when that sub/method runs, I get this error:

encountered object 'Reference {"key" => "value","otherkey" => "otherva +lue","email...} did not pass type constraint "Object" (in $_{"user"})

At the point where the sub/method is supposed to return some data.

So what are my next steps? That looks to me like a logical perl object, except for the bare string 'Reference' at the start.

Any ideas gratefully received.

  • Comment on Moose throwing error with some data which doesn't match the 'Object' constraint, what should I do?
  • Select or Download Code

Replies are listed 'Best First'.
Re: Moose throwing error with some data which doesn't match the 'Object' constraint, what should I do?
by choroba (Cardinal) on Jan 18, 2022 at 17:34 UTC
    Moose doesn't provide validate_subs. I can't even find any MooseX package providing it. I only see it in MooX::ValidateSubs. Is that what you're using?

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      Oh damn, but yes, that must be what's going on. Thanks for your help, back to the drawing board etc.!

Re: Moose throwing error with some data which doesn't match the 'Object' constraint, what should I do?
by Anonymous Monk on Jan 18, 2022 at 07:08 UTC
Re: Moose throwing error with some data which doesn't match the 'Object' constraint, what should I do?
by Anonymous Monk on Jan 18, 2022 at 08:49 UTC

    So what are my next steps? That looks to me like a logical perl object, except for the bare string 'Reference' at the start

    that's a plain reference/ plain hash reference, not an object

    perlglossary doesn't list a logical perl object

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11140548]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-19 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found