MooseX::Constructor::AllErrors::Error::TypeConstraint - represents a type constraint validation error


MooseX-Constructor-AllErrors documentation Contained in the MooseX-Constructor-AllErrors distribution.

Index


Code Index:

NAME

Top

MooseX::Constructor::AllErrors::Error::TypeConstraint - represents a type constraint validation error

VERSION

Top

version 0.016

DESCRIPTION

Top

This class represents the failure to validate an attribute's type constraint.

METHODS

Top

message

Returns a human-readable error message for this error.

attribute

The Moose::Meta::Attribute object that this error relates to.

SEE ALSO

Top

Moose

AUTHOR

Top

  Hans Dieter Pearcey <hdp@cpan.org>

COPYRIGHT AND LICENSE

Top


MooseX-Constructor-AllErrors documentation Contained in the MooseX-Constructor-AllErrors distribution.

package MooseX::Constructor::AllErrors::Error::TypeConstraint;
BEGIN {
  $MooseX::Constructor::AllErrors::Error::TypeConstraint::VERSION = '0.016';
}

use Moose;
extends 'MooseX::Constructor::AllErrors::Error';

has attribute => (
    is => 'ro',
    isa => 'Moose::Meta::Attribute',
    required => 1,
);

# for internal use only
has data => (
    is => 'ro',
    required => 1,
);

sub message {
    my $self = shift;
    return sprintf
        'Attribute (%s) does not pass the type constraint because: %s',
        $self->attribute->name,
        $self->attribute->type_constraint->get_message($self->data);
}

1;
__END__