An Angular directive for validating a routing number input field.
angular-aba-routing-validation' in your module's dependencies:
Simply add the
routing-number attribute to your
The directive attaches four properties to the
$error property of your form field, so they can be used like any of the built-in validation directives (like
formName.fieldName.$error.abaRouting- the provided routing number fails validation (invalid length, invalid starting number, or fails algorithm check). Note that this does not set an error if the model is empty (
"") so that you can make the input conditionally optional. You'll need to include
ng-requiredto error when the model is empty.
formName.fieldName.$error.abaRoutingInternal- the provided routing number indicates a bank's internal routing number (begins with a 5) and is not a valid account routing number
formName.fieldName.$error.abaRoutingMinLength- the provided routing number is too short (less than 9 digits)
formName.fieldName.$error.abaRoutingMaxLength- the provided routing number is too long (more than 9 digits) - this probably shouldn't happen because
ng-maxlengthis automatically applied, which should restrict the user from being able to type in more than 9 characters, but...
This directive also includes
x-autocompletetype="routing-transit-number" for good measure.
A round of tests is included. To run the tests, execute:
Contributions are always welcome. Please submit issues and pull requests.