Skip Menu |

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

Report information
The Basics
Id: 102184
Status: resolved
Priority: 0/
Queue: Data-Sah

People
Owner: Nobody in particular
Requestors: mila [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



hi. i encounter an fatal error 'Argument "test_abc" isn't numeric in addition (+)...' when executing an validator. the validator dies when the return type is 'str', but with an return_type 'bool' the validation works as expected. the error condition is also dependent of he input data. to illustrate this i attached an example script. schema: [ array => { of => [ 'hash', 'keys' => { test_abc => [ 'array', 'of', 'any' ] } ] } ]; test data1: [{ test_abc => ["a"] }] => validation works (str and bool return_type) test data2: [{ test_abc => ["a"] }, { test_abc => ["b"] }] => validation return_type=>bool works, return_type=>str dies with 'Argument "test_abc" isn't numeric in addition (+)...' i get this error with Data::Sah version 0.42 on perl 5.20.1 (linux) thanks, michael
Subject: sah.pl
use Data::Sah qw(normalize_schema gen_validator); use Data::Dump; my $def = [ array => { of => [ 'hash', 'keys' => { test_abc => [ 'array', 'of', 'any' ] } ] } ]; eval { for my $return_type (qw(bool str)) { my $data = []; print "\n>>> return_type: $return_type\n"; for ( 0 .. 1 ) { push @$data, { test_abc => ['a'] }; ddx $data; print "validate > ", gen_validator( $def, { return_type => $return_type } )->($data), "\n"; } } }; print "ERR: $@\n\n" if $@;
Hi, Thanks for the report. This is caused by improper push/pop of internal state variable (_sahv_dpath). Fixed in 0.43. On Tue Feb 17 15:59:19 2015, MILA wrote: Show quoted text
> hi. i encounter an fatal error 'Argument "test_abc" isn't numeric in > addition (+)...' when executing an validator. > > the validator dies when the return type is 'str', but with an > return_type 'bool' the validation works as expected. the error > condition is also dependent of he input data. to illustrate this i > attached an example script. > > schema: > [ > array => { > of => [ > 'hash', > 'keys' => { > test_abc => [ 'array', 'of', 'any' ] > } > ] > } > ]; > > test data1: > [{ test_abc => ["a"] }] > > => validation works (str and bool return_type) > > test data2: > [{ test_abc => ["a"] }, { test_abc => ["b"] }] > > => validation return_type=>bool works, return_type=>str dies with > 'Argument "test_abc" isn't numeric in addition (+)...' > > i get this error with Data::Sah version 0.42 on perl 5.20.1 (linux) > > thanks, michael