An open API service indexing awesome lists of open source software.

https://github.com/anonrig/ajv-swedish-ssn

AJV plugin for checking Swedish SSN validity
https://github.com/anonrig/ajv-swedish-ssn

Last synced: 3 months ago
JSON representation

AJV plugin for checking Swedish SSN validity

Awesome Lists containing this project

README

          

# ajv-swedish-ssn

Adds a `swedish-ssn` format to [Ajv](https://ajv.js.org).

## Install

```bash
npm i --save ajv-swedish-ssn
```

## Setup

```javascript
import Ajv from 'ajv'
import ssnValidator from 'ajv-swedish-ssn'
const ajv = new Ajv()
ssnValidator(ajv)
```

## Usage

When defining your JSON schema, use the `format` keyword with ther value set to `swedish-ssn`. For example

```json
{
"type": "object",
"properties": {
"ssn": {
"type": "string",
"format": "swedish-ssn"
}
}
}
```