4 use MooseX::Params::Validate;
9 has 'id' => ( is => 'ro', isa => 'Str', default => '1.10.100' );
12 my ($self, %args) = validated_hash( \@_,
13 padded => { isa => 'Bool', optional => 1, default => 0 },
16 # 1.10.100 => 0001.0010.0100
17 my $id = $args{ padded }
18 ? join( '.', map { sprintf( "%04d", $_ ) } split( /\./, $self->id ) )
25 use Test::More tests => 4;
29 isa_ok( my $foo = Foo->new(), 'Foo', 'new' );
31 is( $foo->id, '1.10.100', 'id' );
33 is( $foo->to_string, '1.10.100', 'to_string' );
35 is( $foo->to_string( padded => 1 ), '0001.0010.0100', 'to_string( padded => 1 )' );