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

First name and last name share the same range #50

Closed
stropitek opened this issue Feb 21, 2024 · 4 comments · Fixed by #51
Closed

First name and last name share the same range #50

stropitek opened this issue Feb 21, 2024 · 4 comments · Fixed by #51

Comments

@stropitek
Copy link
Contributor

At least on Swiss driving license

CleanShot 2024-02-21 at 14 19 04

@stropitek
Copy link
Contributor Author

I'm not sure if this is a bug or a feature

@targos
Copy link
Member

targos commented Feb 21, 2024

Ranges are the full ranges used by the parser. The info you're looking for should be directly on the field. For example:

expect(result.details[result.details.length - 1]).toStrictEqual({
label: 'First name',
field: 'firstName',
value: 'FABIENNE',
valid: true,
ranges: [
{
line: 2,
start: 0,
end: 30,
raw: 'MARCHAND<<FABIENNE<<<<<<<<<<<<',
},
],
line: 2,
start: 10,
end: 18,
autocorrect: [],
});

   line: 2, 
   start: 10, 
   end: 18,

@stropitek
Copy link
Contributor Author

Thanks!

@stropitek stropitek closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2024
@stropitek
Copy link
Contributor Author

The start, end properties could be better when there is an issue with the character in the line. For example when some numbers are present in the name.

@stropitek stropitek reopened this Feb 23, 2024
targos added a commit that referenced this issue Feb 23, 2024
When a value doesn't match the expected regex, it still has a clear value with start and end indexes.

BREAKING CHANGE: The result's `details` may now include a non-null `value` even when it's invalid.
The `start` and `end` fields will refer to it instead of the entire range when that happens.
The `fields` object is unchanged and still contains `null` for invalid fields.

Closes: #50
targos added a commit that referenced this issue Feb 23, 2024
When a value doesn't match the expected regex, it still has a clear value with start and end indexes.

BREAKING CHANGE: The result's `details` may now include a non-null `value` even when it's invalid.
The `start` and `end` fields will refer to it instead of the entire range when that happens.
The `fields` object is unchanged and still contains `null` for invalid fields.

Closes: #50
targos added a commit that referenced this issue Feb 23, 2024
When a value doesn't match the expected regex, it still has a clear value with start and end indexes.

BREAKING CHANGE: The result's `details` may now include a non-null `value` even when it's invalid.
The `start` and `end` fields will refer to it instead of the entire range when that happens.
The `fields` object is unchanged and still contains `null` for invalid fields.

Closes: #50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants