New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

french-ssn

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

french-ssn

🇫🇷 A parser / validator for French Social Security Number

  • 4.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

🇫🇷 French Social Security Number Parser

tested with jest npm version CircleCI Build Status codecov

"A la carte" parsing, validation and creation of French Social Security Numbers (named by French people as "Carte Vitale", "Numéro de sécu", "Numéro de sécurité sociale", "NIR", "Carte de sécu" ...)

Installation

yarn add french-ssn

or

npm i --save french-ssn

Usage

import SSN from "french-ssn"

SSN.parse("2 55 08 14 168 025 38")
/*
{
  provisional: false,
  gender: {
    name: 'female',
    title: 'Mme',
  },
  approximateAge: 62,
  birth: {
    month: {
      name: 'août',
      index: 8
    },
    year: 1955,
    approximateDate: 1955-08-17T00:00:00.000Z,
    country: {
      insee: '100',
      name: 'France'
    },
    county: {
      insee: '14',
      name: 'Calvados'
    },
    city: {
      insee: '14168'
    }
  }
}
*/

SSN.validate("2 55 08 14 168 025 12") // false
SSN.validate("2 55 08 14 168 025 38") // true
SSN.getControlKey("2 55 08 14 168 025") // "38"
SSN.make({ gender: 1, month: 5, year: 78, place: "99330", rank: 108 }) // "178059933010817"
SSN.format("178059933010817") // "1 78 05 99 330 108 17"

Api

Methodarguments returned value throws
parsessn: string | number : You may provide your ssn in various formats : a number with 15 digits, a string, with or without spaces, or any other delimiting characteran object containing information about the ssn ownerwill throw if ssn is not correctly formated or if control key does not match. Will not throw if information provided does not make sense, information will simply be marked as "unknown". Eg: parse("0 ...").gender = { unknown: true }
validatessn: string | numberboolean (this is only a convenience function, it calls parse under the hood in a try catch block)never
getControlKeypartialSSN: string | number : The first 13 characters of the ssn string : the control key (2 digits between "01" and "97")will throw if ssn is not correctly formated
makeparams: { gender: string? | number?, month: string? | number?, year: string? | number?, place: string? | number?, rank: string? | number?, controlKey: string? | number? }string Mostly useful for tests, this function creates an SSN with the given params. If controlKey is not provided it is auto filled with a valid value. All named parameters of the function are optionnal.
formatparams: string | numberstring it prints an SSN nicely with spaceswill throw if ssn is not correctly formated

Features

  • Corsica (2A, 2B)
  • DOM-TOM
  • Birth in Foreign countries
  • Birth in Algeria before 1962
  • Birth in Morocco or Tunisia before 1964
  • No dependencies (only dev dependencies)

Contributing

Please fork this package, and run

yarn install
yarn test

Issues

Something is not working as expected? Some data is wrong? Documentation is missing? You need a different feature / API? Please file an issue, we'll be in touch.

References

(in French)

Financial Support

Gofer 🤝 (the human-centric work-on-demand solution) is the main support of this package.

Keywords

FAQs

Package last updated on 21 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc