Here's an example code which validates IBAN and BIC using Swift 5:
main.swift2199 chars56 lines
The code above is creating two classes: IBAN
and BIC
. Each class has a static function validate
that accepts an IBAN or BIC number as a string parameter, and returns an enumerated ValidationResult
which either .valid
or .invalid
with corresponding error message.
The validation logic for IBAN follows the rules as stated in this document: https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN.
The validation logic for BIC follows the official SWIFT documentation: https://www2.swift.com/uhbonline/books/public/en_uk/l2/l2_standard_format.htm.
gistlibby LogSnag