perl - Why does this attempt to customize a type constraint error message fail? -


the following construct creates type constraint functions expected (checks "roles::thing" role when attribute set) when attribute rejected due not passing constraint expect custom error message "not thing" appear; default error message still being given. doing wrong?

role_type 'doesthing', {    role => 'roles::thing',    message => sub { "not thing." } }; 

update: did not provide enough context in original post. way trying use new type is:

has things => (   isa => 'arrayref[doesthing]' ); 

the type validation work expected; still default error message. custom "not thing" error message not propagated have expected be.

the error message arrayref type, regardless of you're expecting inside it.

to custom error message you'll need incorporate arrayref type declaration:

subtype 'arrayofthings',      'arrayref[roles::thing]',      message { 'not array of things' }; 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -