feat: check for valid input checksum
This commit is contained in:
parent
61a8dd4ea4
commit
1ea507583d
1 changed files with 4 additions and 0 deletions
|
|
@ -140,7 +140,11 @@ function mrzCleanResult(obj: Record<string, string>) {
|
|||
}
|
||||
|
||||
export function checkSum(data: string) {
|
||||
if (!/[0-9A-Z<]/.test(data)) return null;
|
||||
|
||||
const sum = data.split('').reduce((a, v, i) => {
|
||||
if (v === '<') return a;
|
||||
|
||||
const num = Number(v);
|
||||
const weight = [7, 3, 1][i % 3];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue