This library is for parsing Business Identifier Codes (BIC) used e.g. in banking. The implementation is based on ISO 9362 Fourth edition 2014-12-01.
Represents a Business Identifier Code (BIC) as an opaque type.
String
Business party prefix (4 alpha-numeric).
Iso3166.CountryCode
CountryCode (ISO 3166). Just an alias to Iso3166.CountryCode from rl-king/elm-iso3166-country-codes
String
Business party suffix (2 alpha-numeric).
String
Branch identifier (3 alpha-numeric).
The branch code is optional ("XXX" for primary office). Where an eight digit BIC code is given, it may be assumed that it refers to the primary office.
fromString : String -> Result Error BIC
Try to parse a String
into a BIC
. Spaces in that String
will
be removed and all letters will be upcased.
fromString "FDDO DE MM" -- Ok (BIC "FDDO" Iso3166.DE "MM" Nothing)
fromString "FDDO DE MM XXX" -- Ok (BIC "FDDO" Iso3166.DE "MM" Nothing)
fromString "axisinbb002" -- Ok (BIC "AXIS" Iso3166.IN "BB" (Just "002"))
Parser errors potentially returned by fromString
.
fromString "FDDO" -- Err LengthError
fromString "FDDODEMMXXX Q" -- Err LengthError
fromString "FD @! DEMMXXX" -- Err NotAlphaNumeric
fromString "FDDO QQ MMXXX" -- Err UnknownCountryCode
toString : BIC -> String
Convert BIC
to an either 8 or 11 character String
, depending on the
availability of the branch code.
-- bic == BIC "FDDO" Iso3166.DE "MM" Nothing
toString bic -- "FDDODEMM"
-- bic == BIC "AXIS" Iso3166.IN "BB" (Just "002")
toString bic -- "AXISINBB002"
toString11 : BIC -> String
Convert BIC
to an 11 character String
, where the branch code will be set
to "XXX"
if it doesn't exist.
-- bic == BIC "FDDO" Iso3166.DE "MM" Nothing
toString11 bic -- "FDDODEMMXXX"
-- bic == BIC "AXIS" Iso3166.IN "BB" (Just "002")
toString11 bic -- "AXISINBB002"
toPartyPrefix : BIC -> PartyPrefix
Extract business party prefix from BIC
.
-- bic == BIC "FDDO" Iso3166.DE "MM" Nothing
toPartyPrefix bic -- "FDDO"
toCountryCode : BIC -> CountryCode
Extract country code from BIC
.
-- bic == BIC "FDDO" Iso3166.DE "MM" Nothing
toCountryCode bic -- Iso3166.DE
toPartySuffix : BIC -> PartySuffix
Extract business party suffix code from BIC
.
-- bic == BIC "FDDO" Iso3166.DE "MM" Nothing
toPartySuffix bic -- "MM"
toBranchId : BIC -> BranchId
Extract branch code from BIC
, using "XXX"
if not available.
-- bic == BIC "FDDO" Iso3166.DE "MM" Nothing
toBranchId bic -- "XXX"
-- bic == BIC "AXIS" Iso3166.IN "BB" (Just "002")
toBranchId bic -- "002"
toOptionalBranchId : BIC -> Maybe BranchId
Extract branch code from BIC
if available.
-- bic == BIC "FDDO" Iso3166.DE "MM" Nothing
toOptionalBranchId bic -- Nothing
-- bic == BIC "AXIS" Iso3166.IN "BB" (Just "002")
toOptionalBranchId bic -- Just "002"