Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,40 @@
|
|||
import std.stdio;
|
||||
|
||||
void main() {
|
||||
auto isins = [
|
||||
"US0378331005",
|
||||
"US0373831005",
|
||||
"U50378331005",
|
||||
"US03378331005",
|
||||
"AU0000XVGZA3",
|
||||
"AU0000VXGZA3",
|
||||
"FR0000988040",
|
||||
];
|
||||
foreach (isin; isins) {
|
||||
writeln(isin, " is ", ISINvalidate(isin) ? "valid" : "not valid");
|
||||
}
|
||||
}
|
||||
|
||||
bool ISINvalidate(string isin) {
|
||||
import std.array : appender;
|
||||
import std.conv : to;
|
||||
import std.regex : matchFirst;
|
||||
import std.string : strip, toUpper;
|
||||
|
||||
isin = isin.strip.toUpper;
|
||||
|
||||
if (isin.matchFirst(`^[A-Z]{2}[A-Z0-9]{9}\d$`).empty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto sb = appender!string;
|
||||
foreach (c; isin[0..12]) {
|
||||
sb.put(
|
||||
[c].to!int(36)
|
||||
.to!string
|
||||
);
|
||||
}
|
||||
|
||||
import luhn;
|
||||
return luhnTest(sb.data);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue