NAME
Business::NAB::Types
SYNOPSIS
use Business::NAB::Types qw/
add_max_string_attribute
/;
has [ qw/
process_date
/ ] => (
is => 'ro',
isa => 'NAB::Type::Date',
required => 1,
coerce => 1,
);
...
DESCRIPTION
Package for defining type constraints for use in the Business::NAB namespace. All types are namespaced to NAB::Type::*.
TYPES
- NAB::Type::Date
-
A DateTime object, this will be coerced from the string DDMMYY or DDMMYYYY
- NAB::Type::StatementDate
-
A DateTime object, this will be coerced from the string YYMMDD
- NAB::Type::BRFInt
- NAB::Type::PositiveInt
-
An Int greater than zero
- NAB::Type::PositiveIntOrZero
-
An Int greater than or equal to zero
- NAB::Type::BSBNumber
- NAB::Type::BSBNumberNoDash
-
A Str of the form
/^\d{3}-\d{3}$/A Str of the form
/^\d{6}$/Some file formats for NAB require a BSB with the dash, while other require the BSB without the dash. This is a hard requirement and files will be rejected if you fail to handle it.
The types here are defined so that you can pass either format in and they will be coerced to the correct format for the file type in question.
- NAB::Type::AccountNumber
-
A Str of the form:
* Alpha-Numeric (A-z0-9) * Hyphens & blanks only are valid * Must not contain all blanks or all zerosAnd:
* Leading zeros, which are part of an account number, must be shown * Edit out hyphens where account number exceeds nine characters * Right justified * Leave blank - NAB::Type::Indicator
-
A Str of the form
/^[\ NTWXY]$/ - NAB::Type::Str
-
A Str that is restricted to the BECS EBCDIC character set
METHODS
add_max_string_attribute
Helper method to allow easier definition of NAB::Type::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 'NAB::Type::RecipientNumber'
=> as 'Maybe[NAB::Type::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 => 'NAB::Type::RecipientNumber',
predicate => "_has_recipient_number",
is => 'ro',
required => 0,
);
If you provide a suffix a trigger will be created to honour the requirement. For example:
__PACKAGE__->add_max_string_attribute(
'reel_sequence_number[2:trim_leading_zeros]',
...
);
Will make the trigger remove leading zeros whenever the attribute is set or updated.
Current supported suffixes are:
* trim_leading_zeros