Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/Add latest national ID card version in OCR process #2353

Merged
merged 18 commits into from
Dec 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: CNI rules
By being too strict on the validation rules, we were sometimes missing
the recognition, typically because of a '0' interpreted as a 'O'.
paultranvan committed Dec 15, 2023
commit 63e5551f4289534b6f852e8f357c2f4f22582c46
Original file line number Diff line number Diff line change
@@ -1039,12 +1039,7 @@
"attributesRegex": [
{
"name": "number",
"regex": "^[0-9A-Z]{9}[0-9]<$",
"validationRules": [
{
"validationFn": "checkIdentityCardNumber"
}
],
"regex": "[0-9A-Z]{9}[0-9]<",
"postTextRules": [
{
"regex": ".{2}$"
@@ -1058,7 +1053,7 @@
"regex": "[MF][0-9]{7}[A-Z]{3}",
"postTextRules": [
{
"regex": ".^"
"regex": "^."
},
{
"regex": ".{4}$"
21 changes: 0 additions & 21 deletions packages/cozy-mespapiers-lib/src/helpers/findAttributes.js
Original file line number Diff line number Diff line change
@@ -26,25 +26,6 @@ const removeSpaces = text => {
return text.replace(/\s/g, '')
}

// TODO: should be moved elsewhere?
const checkIdentityCardNumber = identityNumber => {
if (!identityNumber || !identityNumber.match(/[0-9A-Z<]*/)) {
return false
}
const sumControl = identityNumber[identityNumber.length - 2]
const facteurs = [7, 3, 1]
let resultat = 0
for (let i = 0; i < identityNumber.length - 1; i++) {
const c = identityNumber.charAt(i)
if (c === '<') {
continue
}
resultat += parseInt(c, 36) * facteurs[i % 3]
}

return sumControl === resultat % 10
}

/**
* Compute the euclidean distance between two boxes
* @param {object} box1 - normalized box
@@ -368,8 +349,6 @@ const getValidationFnByName = name => {
switch (name) {
case 'checkCountryCode':
return checkCountryCode
case 'checkIdentityCardNumber':
return checkIdentityCardNumber
default:
log('error', 'Unknown validation function', 'getValidationFnByName')
return null