implements error_for_attribute => as {
my ($self, $attr) = @_;
+ my $reader = $attr->get_read_method;
+ my $predicate = $attr->predicate;
if ($self->attribute_is_required($attr)) {
- if ($attr->has_valid_values) {
- my $reader = $attr->get_read_method;
- unless ($attr->check_valid_value($self, $self->$reader)) {
- return "Not a valid value for ".$attr->name;
- }
- }
- my $predicate = $attr->predicate;
unless ($self->$predicate) {
return $attr->name." is required";
}
}
+ if ($self->$predicate && $attr->has_valid_values) {
+ unless ($attr->check_valid_value($self, $self->$reader)) {
+ return "Not a valid value for ".$attr->name;
+ }
+ }
return; # ok
};