This library provides the functions to validate UK sort code and account number
according to the specification provided by VocaLink.
The library is implemented in F# and can be used from any .NET project.
Library is available for both the full framework projects (net461) and the .NET Core/Standard projects (netstandard2.0).
If you're planning to use the library from C# (or VB), please check the C# usage guide.
To check the sort code / account number pair you'll need:
You can obtain newest version of both files from VocaLink.
Once you got the files, you can load the data into memory (and potentially cache it) using provided functions:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
|
open UkModulusCheck.Validator
let rules =
match loadRules "valacdos-v490.txt" with
| Ok r -> r
| Error ex -> [] // Handle loading error
let substitutions =
match loadSubstitutions "scsubtab.txt" with
| Ok s -> s
| Error ex -> [] // Handle loading error
|
You can find the details of the functions in the reference docs.
To validate the sort code and account number pair use validateAccountNo
function:
1:
2:
3:
|
match validateAccountNo rules substitutions sortCode accountNumber with
| Valid -> printfn "%s-%s is valid!" sortCode accountNumber
| Invalid reason -> printfn "%s-%s is invalid! Reason: %A" sortCode accountNumber reason
|
For more information about the API and types used by the library please check the reference docs.
namespace UkModulusCheck
module Validator
from UkModulusCheck
val rules : UkModulusCheck.Types.ValidationRule list
Full name: Index.rules
val loadRules : path:string -> Result<UkModulusCheck.Types.ValidationRule list,exn>
Full name: UkModulusCheck.Validator.loadRules
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
val r : UkModulusCheck.Types.ValidationRule list
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
val ex : exn
val substitutions : UkModulusCheck.Types.SortCodeSubstitution list
Full name: Index.substitutions
val loadSubstitutions : path:string -> Result<UkModulusCheck.Types.SortCodeSubstitution list,exn>
Full name: UkModulusCheck.Validator.loadSubstitutions
val s : UkModulusCheck.Types.SortCodeSubstitution list
val validateAccountNo : rulesTable:seq<UkModulusCheck.Types.ValidationRule> -> substitutionTable:seq<UkModulusCheck.Types.SortCodeSubstitution> -> sortCode:UkModulusCheck.Types.SortCode -> accountNo:UkModulusCheck.Types.AccountNumber -> UkModulusCheck.Types.ValidationResult
Full name: UkModulusCheck.Validator.validateAccountNo
val Valid : UkModulusCheck.Types.ValidationResult
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn