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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.