Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Additional: vinUS validation fails on valid vin numbers#2460

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bytestream merged 6 commits intojquery-validation:masterfromwewhite:master
Dec 1, 2022

Conversation

wewhite
Copy link
Contributor

Compare by value and type (===) does not work for this algorithm, as both cd and cdv can be either types at the same time. By comparing by value only (==) cd and cdv can be either integer or string, as a string number will be converted to a number reqardless of type.

Relates to BUG:#2459

Compare by value and type (===) does not work for this algorithm, as both cd and cdv can be either types at the same time.By comparing by value only (==) cd and cdv can be either integer or string, as a string number will be converted to a number reqardless of type.
Copy link
Member

@bytestreambytestream left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please could you add a test, and revert the other changes as line 50 (if ( parseInt(cd) === parseInt(cdv) ) {) seems to be the only relevant change.

}
if ( cd === cdv ) {
// cd and cdv can be either integer string
if ( cd == cdv ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I thinkparseInt() should be used instead. For example,(parseInt("X") === parseInt("X")) === false. Any complaint against that?

Suggested change
if(cd==cdv){
if(parseInt(cd)===parseInt(cdv)){

Copy link
ContributorAuthor

@wewhitewewhiteNov 30, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No, that will not work, if string cd ="X" and string cdv="X" should = true.
line 50 could be 'if (+cd === +cdv')' the plus(+) on a string will evaluate it to an int, other wise it is a string.

In reality, the vin check digit in location 8 should be transliterated to a number not a string.
That way the check digit cd and check digit vin cdv will always be a number.

@wewhite
Copy link
ContributorAuthor

I've rewritten the for loop, and removed the nested loop, different commit on my branch.
Will create a test.

@wewhite
Copy link
ContributorAuthor

wewhite commentedDec 1, 2022
edited
Loading

Code is better now, replaced nested for loop with an array index lookup.
Created test cases, added to the test/index file, and created a separate additional vinUS.js test file.

@bytestreambytestream changed the titleRemoved === compare, changed to ==Additional: vinUS validation fails on valid vin numbersDec 1, 2022
@bytestreambytestream merged commit13b859e intojquery-validation:masterDec 1, 2022
@bytestream
Copy link
Member

Thanks ❤️

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@bytestreambytestreambytestream approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Additional validation vinUS fails to validate valid Vehicle Identification Number (VIN).
2 participants
@wewhite@bytestream

[8]ページ先頭

©2009-2025 Movatter.jp