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

isValid and isPerson pass when they should fail #16

Closed
stefanhar opened this issue May 14, 2021 · 3 comments
Closed

isValid and isPerson pass when they should fail #16

stefanhar opened this issue May 14, 2021 · 3 comments

Comments

@stefanhar
Copy link

The national id 1337991337 passes isValid and isPerson checks.

const { isPerson, isValid } = require('kennitala')
const nationalId = '1337991337'
console.log('isValid(nationalId)', isValid(nationalId))
console.log('isPerson(nationalId)', isPerson(nationalId))
@HermannBjorgvin
Copy link
Owner

Looks like we are not checking the months being 01-12, will add a fix and version bump to 1.2.6 this weekend.

Thanks for opening an issue

@HermannBjorgvin
Copy link
Owner

If you want to NPM patch your local version you could change the isPerson and isCompany functions

    function isPerson(kt) {
        var d = parseInt(kt.substr(0, 2), 10);
        var y = parseInt(kt.substr(2, 4), 10);

        return d > 0 && d <= 31 && y > 0 && y <= 12;
    }

    // Companies have first two characters between 41-71
    function isCompany(kt) {
        var d = parseInt(kt.substr(0, 2), 10);
        var y = parseInt(kt.substr(2, 4), 10);

        return d > 40 && d <= 71 && y > 0 && y <= 12;
    }

@HermannBjorgvin
Copy link
Owner

Went ahead and fixed this in 1.2.6 #17

Thanks for the help

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

No branches or pull requests

2 participants