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

Reply via email to