Subtypes

use Moose::Util::TypeConstraints; subtype 'PositiveInt' => as 'Int' => where { $_ > 0 } => message { "$_ is not a positive number." };

We've just created a 'PositiveInt' type which can be used as a type constraint requiring the value provided to be a number greater than 0:

has year => ( isa => 'PositiveInt', is => 'rw', );