Skip to content

Commit 6f71a39

Browse files
committed
chore(issuer): update to use regex for check date format
1 parent e365b10 commit 6f71a39

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

packages/polymath-issuer/src/utils/parsers/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,8 @@ export function parseWhitelistCsv(file: string) {
131131
return false;
132132
}
133133
if (value.split('/').length === 3) {
134-
const year = value.split('/')[2];
135-
if (year.length < 4) {
136-
return false;
137-
}
138-
return moment(value, 'MM/DD/YYYY').toDate();
134+
const regex = /\d\d?\/\d\d?\/\d{4}/;
135+
return regex.test(value) && moment(value, 'M/D/YYYY').toDate();
139136
}
140137
if (numericalRegex.test(value)) {
141138
return new BigNumber(value);

packages/polymath-issuer/testUtils/fixtures/csvFiles.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export const validWhitelistCsv = `\
22
ETH Address,Sell Restriction Date,Buy Restriction Date,KYC/AML Expiry Date,Can Buy From STO,Exempt From % Ownership,Is Accredited,Non-Accredited Limit
3-
0x592E80AD45c08aba6C5bBd2d5C5A097BDF35Dee1,1/1/22,6/4/24,1/1/21,TRUE,TRUE,FALSE,
4-
0xd9f346Bf88cA2cb7e11B0106018DE80A0169764D,12/21/30,12/21/30,10/10/24,TRUE,,TRUE,
5-
0xA1833Cd1a3e72335DE0b6945b5d83247F234d6e8,,,12/1/25,,TRUE,,1000
6-
0x07889A89C6854bb4Ec445825E680255b17751192,,,12/1/25,TRUE,TRUE,,
3+
0x592E80AD45c08aba6C5bBd2d5C5A097BDF35Dee1,1/1/2022,6/4/2024,1/1/2021,TRUE,TRUE,FALSE,
4+
0xd9f346Bf88cA2cb7e11B0106018DE80A0169764D,12/21/2030,12/21/2030,10/10/2024,TRUE,,TRUE,
5+
0xA1833Cd1a3e72335DE0b6945b5d83247F234d6e8,,,12/1/2025,,TRUE,,1000
6+
0x07889A89C6854bb4Ec445825E680255b17751192,,,12/1/2025,TRUE,TRUE,,
77
`;
88

99
export const invalidWhitelistCsv = `\

0 commit comments

Comments
 (0)