Git Product home page Git Product logo

sweden-national-id's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m @MartinAskestad
  • ๐Ÿ‘€ Iโ€™m interested in game development with #Godot and changing my vim-configuration.
  • ๐ŸŒฑ Iโ€™m currently learning Godot game development
  • ๐Ÿ’ž๏ธ Iโ€™m looking to collaborate on Sokoban level genration.
  • ๐Ÿ“ซ How to reach me @Smetad_Anarkist on Twitter.

sweden-national-id's People

Contributors

dependabot[bot] avatar martinaskestad avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

rondeo

sweden-national-id's Issues

Error: unknown format

Receiving an unexpected error when trying to parse random strings. I'd expect it to return null like in the documentation, not throw an error:

import { FinnishSSN } from "finnish-ssn";
import { parse as parseSweSSN } from "sweden-national-id";

export function isValidSSN(ssn: string): boolean {
    if (FinnishSSN.validate(ssn)) return true;
    const sweSSN = parseSweSSN(ssn);
    if (sweSSN) return true;
    return false;
}
Error: unknown format
     at format (node_modules/sweden-national-id/dist/format.js:24:19)
     at parse (node_modules/sweden-national-id/dist/national-id-number.js:24:50)
     at isValidSSN (file:///home/perry/<snip>/bots/dist/test/projects/shared/library/ssn.js:6:20)
     at validateStringWithoutPII (file:///home/perry/<snip>/bots/dist/test/projects/shared/schemaHelpers.js:136:13)
     at Context.<anonymous> (file:///home/perry/<snip>/bots/dist/test/test/shared/unit/schemaHelpers.spec.js:40:20)
     at process.processImmediate (node:internal/timers:478:21)

Value can be literally anything, and it breaks.

For instance, I was testing segments of a piece of text, looking for a Swedish SSN, and it broke on every value:

export function isValidSSN(ssn: string): boolean {
    if (FinnishSSN.validate(ssn)) return true;
    try {
        const sweSSN = parseSweSSN(ssn);
        if (sweSSN) return true;
    } catch (err) {
        console.error("SSN ERR:    "+ssn);
        return false;
    }
    return false;
}
SSN TEST:    my
SSN TEST:    number
SSN TEST:    is
SSN TEST:    my
SSN TEST:    number
SSN TEST:    is
SSN TEST:    0439200192.

I'm using Node 20 under docker, with typescript v5.

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.