NAME
Business::Westpac::Types
SYNOPSIS
use Business::Westpac::Types qw/
add_max_string_attribute
/;
has [ qw/
funding_bsb_number
/ ] => (
is => 'ro',
isa => 'BSBNumber',
required => 0,
);
...
DESCRIPTION
Package for defining type constraints for use in the Business::Westpac namespace.
TYPES
- WestpacDate
-
A DateTime object, this will be coerced from the string DDMMYYYY
- PositiveInt
-
An Int greater than zero
- PositiveNum
-
A Num greater than zero
- BSBNumber
-
A Str of the form
/^\d{3}-\d{3}$/
METHODS
add_max_string_attribute
Helper method to allow easier definition of Str types that are limited to a particular lengths. For example:
__PACKAGE__->add_max_string_attribute(
'RecipientNumber[20]'
is => 'ro',
required => 0,
);
Is equivalent to:
subtype 'RecipientNumber'
=> as 'Maybe[Str]'
=> where {
! defined( $_ )
or length( $_ ) <= 20
}
=> message {
"The string provided for recipient_number"
. " was outside 1..20 chars"
}
;
__PACKAGE__->meta->add_attribute( 'recipient_number',
isa => 'RecipientNumber',
predicate => "_has_recipient_number",
is => 'ro',
required => 0,
);