Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^2: Attribute does not pass Type Constraint

by PerlSufi (Friar)
on Apr 03, 2014 at 18:44 UTC ( #1080990=note: print w/replies, xml ) Need Help??

in reply to Re: Attribute does not pass Type Constraint
in thread Attribute does not pass Type Constraint

Thanks for the response tobyink.
I'm starting to see now that maybe the addition of MooseX::UndefTolerant might have helped- not sure yet. I am getting this error from my test file, but the line it is complaining about is in the following subroutine:
my $class = shift; my (%args) = validated_hash( \@_, id => { isa => 'Int' }, ticket_user => { isa => 'Customer::TicketUser' }, ); my $ticket_response = $class->_ticket_api_request( { method => 'get', route => 'user/' . $args{ticket_user}->user_id . '/ticket/' . $args{id}, data => undef, } ); my $ticket = $class->new( { id => $args{id}, department_name => $ticket_response->{ticket}{department +}, subject => $ticket_response->{ticket}{subject}, status_id => $ticket_response->{ticket}{status}, created_time => $ticket_response->{ticket}{created_ti +me}, ticket_user => $args{ticket_user}, } ); my $posts_response = $class->_ticket_api_request( { method => 'get', route => 'user/' . $args{ticket_user}->user_id . '/ticket/' . $args{id} . '/posts', data => undef, } ); my @posts; for my $post_id ( keys $posts_response ) { # HERE my $post = GBClient::Model::Support::Ticket::Post->from_json +( { ticket => $ticket, json => $posts_response->{$post_id} } ); push @posts, $post; }

Replies are listed 'Best First'.
Re^3: Attribute does not pass Type Constraint
by PerlSufi (Friar) on Apr 03, 2014 at 21:13 UTC
    I think I may have figured it out. I made the following changes:
    class_type 'DateTime'; subtype 'DT' => as 'Maybe[DateTime]'; coerce 'DT', from 'Str', via { DateTime::Format::DateParse->parse_datetime($_) }; coerce 'DT', from 'Int', via { DateTime->from_epoch( epoch => $_ ) }; ... has created_time => ( is => 'rw', isa => 'DT', required => 0, coerce => 1, ); # and then in the subroutine I posted earlier: ... for my $post_id ( keys %$post_response ) { # changed to unblessed ...
    But I'm now getting an error about something else in the module. So I will follow up as necessary :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1080990]
[Corion]: In fact, the whole thing is just four simple programs, one App::scrape, another being DBIx::RunSQL, and one some glue to convert a JSON object into an SQL INSERT statement (+DBI connect/execute), so it would be an incredibly simple solution...
[Corion]: ... but that simplicity falls down due to SQLite letting me down and me being too lazy to move to a real DB. Maybe DBD::CSV can handle window functions...
[hippo]: Pg has the "trust" mechanism if you don't fancy using credentials for a trivial db.
[Corion]: hippo: Oooh, that sounds quite nice - let me read the documentation on that :)
[hippo]: https://www. docs/current/ static/auth- methods.html#AUTH- TRUST
[erix]: or compile & run an instance as yourself (not user 'postgres')
[erix]: easiest setup is to run with PG* env variables set, and a custom .pgpass files (can be a $PGPASSFILE)
[Corion]: Hmm - "trust" sounds interesting, but I have still to find whether I can restrict that on a per-DB level ;)
[Corion]: erix: Sure, but SQLite doesn't even need that :)

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2018-02-23 15:10 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (302 votes). Check out past polls.