Coercions

You can coerce values into their type should they not be provided in the format you may want to store them.

An example:

use DateTime; use Date::Parse qw( str2time ); subtype 'Car::ManufactureDate' => as class_type('DateTime'); coerce 'Car::ManufactureDate' => from 'Int' => via { DateTime->from_epoch( epoch => $_ ) } => from 'Str' => via { DateTime->from_epoch( epoch => str2time( $_ ) ) }; has manufacture_date => ( isa => 'Car::ManufactureDate', is => 'rw', coerce => 1, );