Commit 938cf1bc authored by Alasdair Keyes's avatar Alasdair Keyes

Replace tabs with 4 spaces - .vimrc playing up

parent b442d0cd
......@@ -46,9 +46,9 @@ ValueObject::Base - Base object for all value objects
my $value = shift || '';
# if $value validates
# return 1
# return 1
# else
# Throw exception on failer
# Throw exception on failer
}
=head1 DESCRIPTION
......
......@@ -13,18 +13,18 @@ sub new {
my $class = shift;
my $value = shift;
my $boolean_object;
my $boolean_object;
foreach my $boolean_type ('ValueObject::Boolean::YesNo','ValueObject::Boolean::TrueFalse','ValueObject::Boolean::OnOff') {
$boolean_object = eval {
$boolean_type->new($value);
};
if ($boolean_object) {
return $boolean_object;
}
}
foreach my $boolean_type ('ValueObject::Boolean::YesNo','ValueObject::Boolean::TrueFalse','ValueObject::Boolean::OnOff') {
$boolean_object = eval {
$boolean_type->new($value);
};
if ($boolean_object) {
return $boolean_object;
}
}
croak (ValueObject::Boolean::Exception::Invalid->new($value));
croak (ValueObject::Boolean::Exception::Invalid->new($value));
}
1;
......@@ -6,8 +6,8 @@ use Carp;
use base qw/ ValueObject::Base /;
sub boolean {
my $self = shift;
croak "Invalid boolean function for " . (ref($self) || $self);
my $self = shift;
croak "Invalid boolean function for " . (ref($self) || $self);
}
1;
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid boolean';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid boolean';
return $class->SUPER::new($message, @_);
}
1;
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid on/off boolean';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid on/off boolean';
return $class->SUPER::new($message, @_);
}
1;
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid true/false boolean';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid true/false boolean';
return $class->SUPER::new($message, @_);
}
1;
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid yes/no boolean';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid yes/no boolean';
return $class->SUPER::new($message, @_);
}
1;
......@@ -17,16 +17,16 @@ my @off = (
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Boolean::Exception::InvalidOnOff->new($value))
croak (ValueObject::Boolean::Exception::InvalidOnOff->new($value))
unless (grep { lc($_) eq lc($value) } @on, @off);
return 1;
}
sub boolean {
my $self = shift;
return (grep { $_ eq lc($self->value) } @on)
? 1
: 0;
my $self = shift;
return (grep { $_ eq lc($self->value) } @on)
? 1
: 0;
}
1;
......@@ -19,16 +19,16 @@ my @false = (
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Boolean::Exception::InvalidTrueFalse->new($value))
croak (ValueObject::Boolean::Exception::InvalidTrueFalse->new($value))
unless (grep { lc($_) eq lc($value) } @true, @false);
return 1;
}
sub boolean {
my $self = shift;
return (grep { $_ eq lc($self->value) } @true)
? 1
: 0;
my $self = shift;
return (grep { $_ eq lc($self->value) } @true)
? 1
: 0;
}
1;
......@@ -19,16 +19,16 @@ my @no = (
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Boolean::Exception::InvalidYesNo->new($value))
croak (ValueObject::Boolean::Exception::InvalidYesNo->new($value))
unless (grep { lc($_) eq lc($value) } @yes, @no);
return 1;
}
sub boolean {
my $self = shift;
return (grep { $_ eq lc($self->value) } @yes)
? 1
: 0;
my $self = shift;
return (grep { $_ eq lc($self->value) } @yes)
? 1
: 0;
}
1;
......@@ -8,33 +8,33 @@ use overload
'""' => \&overload_message;
sub new {
my $class = shift;
my $message = shift || '';
my $value = shift;
$value = (defined($value))
? $value
: 'undef';
return bless {
message => $message,
value => $value,
}, $class;
my $class = shift;
my $message = shift || '';
my $value = shift;
$value = (defined($value))
? $value
: 'undef';
return bless {
message => $message,
value => $value,
}, $class;
}
sub message {
my $self = shift;
return $self->{ message };
my $self = shift;
return $self->{ message };
}
sub value {
my $self = shift;
return $self->{ value };
my $self = shift;
return $self->{ value };
}
sub overload_message {
my $self = shift;
return (ref($self) || $self) . ' - ' . $self->message . ' (' . $self->value . ')' . Carp::longmess();
my $self = shift;
return (ref($self) || $self) . ' - ' . $self->message . ' (' . $self->value . ')' . Carp::longmess();
}
1;
......@@ -172,8 +172,8 @@ my $currency_codes = {
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Finance::Currency::Exception::InvalidCode->new($value))
unless ($currency_codes->{ lc($value) });
croak (ValueObject::Finance::Currency::Exception::InvalidCode->new($value))
unless ($currency_codes->{ lc($value) });
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid currency code';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid currency code';
return $class->SUPER::new($message, @_);
}
1;
......@@ -12,18 +12,18 @@ sub new {
my $class = shift;
my $value = shift;
my $currency_object;
my $currency_object;
foreach my $currency_type ('ValueObject::Finance::Money::Period', 'ValueObject::Finance::Money::Comma') {
$currency_object = eval {
$currency_type->new($value);
};
if ($currency_object) {
return $currency_object;
}
}
foreach my $currency_type ('ValueObject::Finance::Money::Period', 'ValueObject::Finance::Money::Comma') {
$currency_object = eval {
$currency_type->new($value);
};
if ($currency_object) {
return $currency_object;
}
}
croak (ValueObject::Finance::Money::Exception::Invalid->new($value));
croak (ValueObject::Finance::Money::Exception::Invalid->new($value));
}
1;
......@@ -9,8 +9,8 @@ use base qw/ ValueObject::Finance::Money::Base /;
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Finance::Money::Exception::InvalidComma->new($value))
unless ($value =~ /^\d+,\d{2}$/);
croak (ValueObject::Finance::Money::Exception::InvalidComma->new($value))
unless ($value =~ /^\d+,\d{2}$/);
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid money';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid money';
return $class->SUPER::new($message, @_);
}
1;
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid comma separated money';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid comma separated money';
return $class->SUPER::new($message, @_);
}
1;
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid period separated money';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid period separated money';
return $class->SUPER::new($message, @_);
}
1;
......@@ -9,8 +9,8 @@ use base qw/ ValueObject::Finance::Money::Base /;
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Finance::Money::Exception::InvalidPeriod->new($value))
unless ($value =~ /^\d+\.\d{2}$/);
croak (ValueObject::Finance::Money::Exception::InvalidPeriod->new($value))
unless ($value =~ /^\d+\.\d{2}$/);
return 1;
}
......
......@@ -16,7 +16,7 @@ my @enum = (
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Gender::Exception::Invalid->new($value))
croak (ValueObject::Gender::Exception::Invalid->new($value))
unless (grep { lc($_) eq lc($value) } @enum);
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid gender';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid gender';
return $class->SUPER::new($message, @_);
}
1;
......@@ -9,7 +9,7 @@ use ValueObject::Identity::UUID::Exception::Invalid;
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Identity::UUID::Exception::Invalid->new($value))
croak (ValueObject::Identity::UUID::Exception::Invalid->new($value))
unless ($value =~ /^[0-9a-f]{8}\-[0-9a-f]{4}\-[1-5][0-9a-f]{3}\-[89ab][0-9a-f]{3}\-[0-9a-f]{12}$/);
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid UUID';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid UUID';
return $class->SUPER::new($message, @_);
}
1;
......@@ -9,7 +9,7 @@ use ValueObject::Identity::UUIDv1::Exception::Invalid;
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Identity::UUIDv1::Exception::Invalid->new($value))
croak (ValueObject::Identity::UUIDv1::Exception::Invalid->new($value))
unless ($value =~ /^[0-9a-f]{8}\-[0-9a-f]{4}\-1[0-9a-f]{3}\-[89ab][0-9a-f]{3}\-[0-9a-f]{12}$/);
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid version 1 UUID';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid version 1 UUID';
return $class->SUPER::new($message, @_);
}
1;
......@@ -9,7 +9,7 @@ use ValueObject::Identity::UUIDv2::Exception::Invalid;
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Identity::UUIDv2::Exception::Invalid->new($value))
croak (ValueObject::Identity::UUIDv2::Exception::Invalid->new($value))
unless ($value =~ /^[0-9a-f]{8}\-[0-9a-f]{4}\-2[0-9a-f]{3}\-[89ab][0-9a-f]{3}\-[0-9a-f]{12}$/);
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid version 2 UUID';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid version 2 UUID';
return $class->SUPER::new($message, @_);
}
1;
......@@ -9,7 +9,7 @@ use ValueObject::Identity::UUIDv3::Exception::Invalid;
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Identity::UUIDv3::Exception::Invalid->new($value))
croak (ValueObject::Identity::UUIDv3::Exception::Invalid->new($value))
unless ($value =~ /^[0-9a-f]{8}\-[0-9a-f]{4}\-3[0-9a-f]{3}\-[89ab][0-9a-f]{3}\-[0-9a-f]{12}$/);
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid version 3 UUID';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid version 3 UUID';
return $class->SUPER::new($message, @_);
}
1;
......@@ -9,7 +9,7 @@ use ValueObject::Identity::UUIDv4::Exception::Invalid;
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Identity::UUIDv4::Exception::Invalid->new($value))
croak (ValueObject::Identity::UUIDv4::Exception::Invalid->new($value))
unless ($value =~ /^[0-9a-f]{8}\-[0-9a-f]{4}\-4[0-9a-f]{3}\-[89ab][0-9a-f]{3}\-[0-9a-f]{12}$/);
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid version 4 UUID';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid version 4 UUID';
return $class->SUPER::new($message, @_);
}
1;
......@@ -9,7 +9,7 @@ use ValueObject::Identity::UUIDv5::Exception::Invalid;
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::Identity::UUIDv5::Exception::Invalid->new($value))
croak (ValueObject::Identity::UUIDv5::Exception::Invalid->new($value))
unless ($value =~ /^[0-9a-f]{8}\-[0-9a-f]{4}\-5[0-9a-f]{3}\-[89ab][0-9a-f]{3}\-[0-9a-f]{12}$/);
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid version 5 UUID';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid version 5 UUID';
return $class->SUPER::new($message, @_);
}
1;
......@@ -11,7 +11,7 @@ sub validate {
my $self = shift;
my $value = shift || '';
my $email_address = Email::Valid->address($value);
croak (ValueObject::Inet::EmailAddress::Exception::Invalid->new($value))
croak (ValueObject::Inet::EmailAddress::Exception::Invalid->new($value))
unless ($email_address);
return 1;
}
......
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid email';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid email';
return $class->SUPER::new($message, @_);
}
1;
......@@ -12,18 +12,18 @@ sub new {
my $class = shift;
my $value = shift;
my $ip_object;
my $ip_object;
foreach my $ip_type ('ValueObject::Inet::IP::IPv4', 'ValueObject::Inet::IP::IPv6') {
$ip_object = eval {
$ip_type->new($value);
};
if ($ip_object) {
return $ip_object;
}
}
foreach my $ip_type ('ValueObject::Inet::IP::IPv4', 'ValueObject::Inet::IP::IPv6') {
$ip_object = eval {
$ip_type->new($value);
};
if ($ip_object) {
return $ip_object;
}
}
croak (ValueObject::Inet::IP::Exception::Invalid->new($value));
croak (ValueObject::Inet::IP::Exception::Invalid->new($value));
}
1;
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid IP';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid IP';
return $class->SUPER::new($message, @_);
}
1;
......@@ -11,7 +11,7 @@ sub validate {
my $self = shift;
my $value = shift || '';
my $ip = Net::IP->new($value);
croak (ValueObject::Inet::IP::Exception::Invalid->new($value))
croak (ValueObject::Inet::IP::Exception::Invalid->new($value))
unless (
$ip &&
$ip->size == 1 &&
......
......@@ -12,12 +12,12 @@ my $colon_regex = qr/^([0-9a-f][0-9a-f]:){5}([0-9a-f][0-9a-f])$/i;
sub validate {
my $self = shift;
my $value = shift || '';
foreach my $regex ($dash_regex, $colon_regex) {
return 1
if ($value =~ /$regex/);
}
foreach my $regex ($dash_regex, $colon_regex) {
return 1
if ($value =~ /$regex/);
}
croak (ValueObject::Inet::MacAddress::Exception::Invalid->new($value))
croak (ValueObject::Inet::MacAddress::Exception::Invalid->new($value))
}
1;
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid MAC Address';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid MAC Address';
return $class->SUPER::new($message, @_);
}
1;
......@@ -5,9 +5,9 @@ use warnings;
use base qw/ ValueObject::Exception::Base /;
sub new {
my $class = shift;
my $message = 'Invalid port';
return $class->SUPER::new($message, @_);
my $class = shift;
my $message = 'Invalid port';
return $class->SUPER::new($message, @_);
}
1;
......@@ -11,7 +11,7 @@ use ValueObject::PostCode::Exception::Invalid;
sub validate {
my $self = shift;
my $value = shift || '';
croak (ValueObject::PostCode::Exception::Invalid->new($value))