checking consistency between attributes
[email protected] (Guillaume Rousse)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
Hello list.
What's the best way to check consistency between attributes values ? Is
there anything better than a dedicated BUILD method, such as:
use Moose;
use Carp;
has 'min' => (is => 'rw', isa => 'Int');
has 'max' => (is => 'rw', isa => 'Int');
sub BUILD {
my ($self, $params) = @_;
my ($max, $min) = ($self->max(), $self->min());
croak "max < min" if defined $max && defined $min && $max < $min;
}
--
Guillaume Rousse
Moyens Informatiques - INRIA Futurs
Tel: 01 69 35 69 62