}
if ($constraint) {
- $accessor .= 'do {
- my $display = defined($_) ? overload::StrVal($_) : "undef";
- Carp::confess("Attribute ($name) does not pass the type constraint because: Validation failed for \'$type\' failed with value $display") unless $constraint->();
- };'
+ $accessor .= 'unless ($constraint->()) {
+ my $display = defined($_) ? overload::StrVal($_) : "undef";
+ Carp::confess("Attribute ($name) does not pass the type constraint because: Validation failed for \'$type\' failed with value $display");
+ }'
}
$accessor .= '$self->{$key} = $_;';