Validating a bank account number is a two-step process: First you need to validate the clearing number. Why?
This module lets you validate clearing numbers.
Trying to construct a ClearingNumber can fail in two ways:
BadLength
contains how many digits were actually passed. Clearing numbers are
always 4 or 5 digits long.Validate and construct a ClearingNumber.
The clearing number string is allowed to have any kind of crazy formatting. The function simply takes all the digits of the string and discards all other characters. The following all mean the same thing:
9420
94 20
94,20
abc94-2#0!If you have a form field for the clearing number, you might want to normalize
it on blur. You can use String.filter Char.isDigit myString to do so.
Get a string containing digits only (no hyphens or spaces or anything), such as “9420”.
Get a human readable string name of the bank identified from the clearing number, such as “Länsförsäkringar Bank”.
Represents a Swedish clearing number.
The only way to create a value of the
ClearingNumbertype is by callingfromString. This way, if you encounter aClearingNumber, you know that it is always valid.ClearingNumberalso contains information about which Swedish bank the bank account number is for.