return 1 if !$type_constraint;
return 1 if $type_constraint->check($value);
- $self->verify_type_constraint_error($self->name, $value, $type_constraint);
+ $self->verify_type_constraint_error($value, $type_constraint);
}
sub verify_type_constraint_error {
- my($self, $name, $value, $type) = @_;
- $self->throw_error("Attribute ($name) does not pass the type constraint because: "
- . $type->get_message($value));
+ my($self, $value, $type) = @_;
+
+ $self->throw_error(
+ sprintf q{Attribute (%s) does not pass the type constraint because: %s},
+ $self->name,
+ $type->get_message($value),
+ );
}
sub coerce_constraint { # DEPRECATED
$accessor .=
"\n".
'$compiled_type_constraint->('.$value.') or
- $attribute->verify_type_constraint_error($name, '.$value.', $constraint);' . "\n";
+ $attribute->verify_type_constraint_error('.$value.', $constraint);' . "\n";
}
# if there's nothing left to do for the attribute we can return during
$accessor .= "my \$tmp = $value;\n";
$accessor .= "\$compiled_type_constraint->(\$tmp)";
- $accessor .= " || \$attribute->verify_type_constraint_error(\$name, \$tmp, \$constraint);\n";
+ $accessor .= " || \$attribute->verify_type_constraint_error(\$tmp, \$constraint);\n";
$accessor .= "$slot = \$tmp;\n";
}
else{
my $post_process = '';
if(defined $type_constraint){
$post_process .= "\$checks[$index]->($instance_slot)";
- $post_process .= " or $attr_var->verify_type_constraint_error(q{$key}, $instance_slot, $constraint_var);\n";
+ $post_process .= " or $attr_var->verify_type_constraint_error($instance_slot, $constraint_var);\n";
}
if($is_weak_ref){
$post_process .= "Scalar::Util::weaken($instance_slot) if ref $instance_slot;\n";