Anonymous user
IBAN: Difference between revisions
→{{header|Caché ObjectScript}}
m (tt-wrap the value to verify) |
|||
Line 115:
{
ClassMethod
{
// remove spaces and define parts
// ensure IBAN is correct format
If $Match(iban, ..GetIBANPattern(cc))=0 Quit 0
// compare result and return
Quit cd=..GetIBANCheckDigit(cc, bban)
}
ClassMethod
{
Set
▲ Set cc=$Extract(pIBAN, 1, 2)
▲ For i=1:1:$Length(alt) {
▲ Set chr=$Extract(alt, i)
}
Set cd=98-..
}
ClassMethod
{
Set $Extract(pNum, 1, 9)=$Extract(pNum, 1, 9)#pDiv
▲ Set res=(res_$Extract(pNum, 1, 7))#pDiv
▲ Set pNum=$Extract(pNum, 8, *)
}
Quit
}
ClassMethod GetIBANPattern(pCC As %String = "") As %String [ Internal, Private ]
{
Quit $Case(pCC,
"AL": "^AL\d{10}[0-9A-Z]{16}$",
"AD": "^AD\d{10}[0-9A-Z]{12}$",
"AT": "^AT\d{18}$",
"BH": "^BH\d{2}[A-Z]{4}[0-9A-Z]{14}$",
"BE": "^BE\d{14}$",
"BA": "^BA\d{18}$",
"BG": "^BG\d{2}[A-Z]{4}\d{6}[0-9A-Z]{8}$",
"HR": "^HR\d{19}$",
"CY": "^CY\d{10}[0-9A-Z]{16}$",
"CZ": "^CZ\d{22}$",
"DK": "^DK\d{16}$|^FO\d{16}$|^GL\d{16}$",
"DO": "^DO\d{2}[0-9A-Z]{4}\d{20}$",
"EE": "^EE\d{18}$",
"FI": "^FI\d{16}$",
"FR": "^FR\d{12}[0-9A-Z]{11}\d{2}$",
"GE": "^GE\d{2}[A-Z]{2}\d{16}$",
"DE": "^DE\d{20}$",
"GI": "^GI\d{2}[A-Z]{4}[0-9A-Z]{15}$",
"GR": "^GR\d{9}[0-9A-Z]{16}$",
"HU": "^HU\d{26}$",
"IS": "^IS\d{24}$",
"IE": "^IE\d{2}[A-Z]{4}\d{14}$",
"IL": "^IL\d{21}$",
"IT": "^IT\d{2}[A-Z]\d{10}[0-9A-Z]{12}$",
"KZ": "^[A-Z]{2}\d{5}[0-9A-Z]{13}$",
"KW": "^KW\d{2}[A-Z]{4}22!$",
"LV": "^LV\d{2}[A-Z]{4}[0-9A-Z]{13}$",
"LB": "^LB\d{6}[0-9A-Z]{20}$",
"LI": "^LI\d{7}[0-9A-Z]{12}$",
"LT": "^LT\d{18}$",
"LU": "^LU\d{5}[0-9A-Z]{13}$",
"MK": "^MK\d{5}[0-9A-Z]{10}\d{2}$",
"MT": "^MT\d{2}[A-Z]{4}\d{5}[0-9A-Z]{18}$",
"MR": "^MR13\d{23}$",
"MU": "^MU\d{2}[A-Z]{4}\d{19}[A-Z]{3}$",
"MC": "^MC\d{12}[0-9A-Z]{11}\d{2}$",
"ME": "^ME\d{20}$",
"NL": "^NL\d{2}[A-Z]{4}\d{10}$",
"NO": "^NO\d{13}$",
"PL": "^PL\d{10}[0-9A-Z]{,16}n$",
"PT": "^PT\d{23}$",
"RO": "^RO\d{2}[A-Z]{4}[0-9A-Z]{16}$",
"SM": "^SM\d{2}[A-Z]\d{10}[0-9A-Z]{12}$",
"SA": "^SA\d{4}[0-9A-Z]{18}$",
"RS": "^RS\d{20}$",
"SK": "^SK\d{22}$",
"SI": "^SI\d{17}$",
"ES": "^ES\d{22}$",
"SE": "^SE\d{22}$",
"CH": "^CH\d{7}[0-9A-Z]{12}$",
"TN": "^TN59\d{20}$",
"TR": "^TR\d{7}[0-9A-Z]{17}$",
"AE": "^AE\d{21}$",
"GB": "^GB\d{2}[A-Z]{4}\d{14}$",
: " ")
}
}</lang>
{{out|Examples}}
<pre>USER>For { Read iban Quit:iban="" Write " => ", ##class(Utils.Validate).VerifyIBAN(iban), ! }
<pre>▼
GB82 TEST 1234 5698 7654 32 => 0
GR16 0110 1250 0000 0001 2300 695 => 1
GB29 NWBK 6016 1331 9268 19 => 1
SA03 8000 0000 6080 1016 7519 => 1
CH93 0076 2011 6238 5295 7 => 1
IL62 0108 0000 0009 9999 999 => 1
▲USER></pre>
=={{header|Ruby}}==
|