Giter Club home page Giter Club logo

kennitala's People

Contributors

dabbeg avatar davidarnarsson avatar hermannbjorgvin avatar nordfjord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kennitala's Issues

Random numbers from `kennitala.generatePerson` is not following all the rules

According to skra.is, the twoRandomDigits should be from 20 to 99:

Næstu tveir tölustafir hafa enga merkingu og er þeim úthlutað í röð frá og með 20

However the numbers generated in kennitala.generatePerson are:

var twoRandomDigits = "" + Math.floor(Math.random() * 10) + Math.floor(Math.random() * 10)

This rule is also not followed in evaluate.

Bug við 240397 22x

Veit ekki afhverju en alltaf þegar ég slæ inn 240397 22x fær ég alltaf isPerson(...) sem true.

Invalid date is accepted as valid kennitala

The isPerson validation does not account for invalid dates. I see the current code simply checks that the day is <= 31, but 310222 for instance is not a valid date, and hence not a valid kennitala.

Would have to parse the date and validate it.

One way to do it:

const isValid = isNaN(new Date('2022-02-31').getTime())

Related to #16

isValid and isPerson pass when they should fail

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))

Support nationalIds for foreigners

Foreigners get an "invalid" nationalId once registered, which this library will mark as invalid.

It might be better to validate the nationalId, but specify the origin as foreign.
So isPerson(<foreign_national_id>) would return

...
origin: foreign

and isPerson(<native_national_id>) would return

...
origin: native

What's your thought on this?

(This would require a major release bump)

isPerson does not look at the last digit

The last digit is the century, so I would think that future proofing for all upcoming centuries is not correct, that is, I would expect the last digit for a person to only be valid if it is 0 or 9. What do you think about this @HermannBjorgvin ?

Random numbers below 20 are considered valid

In #6 you confirmed that the 7-8th digit should start at 20, and fixed the generator.

But isPerson returns true for the 7-8th numbers below 20.

For instance 070222-0000 returns true, but is invalid.

Aldurs útreikningur getur skeikað einum degi

Lenti í því þegar ég var að athuga hvort einhver væri orðinn 18 ára að kóðinn sem skilar aldri getur gefið nýjan aldur degi fyrir afmælisdag. Dæmi:

var kennitala = require("kennitala")
var today = new Date()
var kt = kennitala.generatePerson(new Date(today.getFullYear()-18, today.getMonth(), today.getDate()+1))
var info = kennitala.info(kt)
info.age

console.log(today)
console.log(kt)
console.log(info)

Þessi aðili ætti að vera 17 ára, en kennitala skilar 18

Úr þessu kemur:

>>> Thu Feb 18 2021 10:31:35 GMT+0000 (Greenwich Mean Time)
>>> "1902037780"
>>> Object
age: 18
birthday: Wed Feb 19 2003 00:00:00 GMT+0000 (Greenwich Mean Time)
birthdayReadable: "Wed Feb 19 2003"
kt: "1902037780"
type: "person"
valid: true

Add exceptions for known test cases (prufumenn)

Add exception for known test case kennitala of ficticious individuals used to test systems (prufumenn).
My main concern is if this will break test cases that rely on prufumenn, would we even want to disqualify those kennitölur since they are still correct.

It's a non breaking change that would affect only test cases but the question is if that's something that's desireable. This library can't validate whether a kennitala is a real person only if it's computationally correct. Would this bring ambiguity to the library?

Sound off if you have an opinion on this. I'm leaning towards not implementing this but I'm not sure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.