@valbo/ajv-strict-formats

Stricter versions of JSON Schema formats for Ajv.

Usage no npm install needed!

<script type="module">
  import valboAjvStrictFormats from 'https://cdn.skypack.dev/@valbo/ajv-strict-formats';
</script>

README

@valbo/ajv-strict-formats

Stricter versions of JSON Schema formats for Ajv.

npm (scoped) semantic-release Build Status Coverage Status Known Vulnerabilities

Install

npm install @valbo/ajv-strict-formats

Usage

Adds time, date-time and uuid formats to Ajv that are stricter than the ones from the ajv-formats package:

import Ajv from 'ajv';
import addFormats from '@valbo/ajv-strict-formats';

const ajv = new Ajv();
addFormats(ajv);

Or add only some formats:

import Ajv from 'ajv';
import addFormats from '@valbo/ajv-strict-formats';

const ajv = new Ajv();
addFormats(ajv, ['date-time', 'uuid']);

time format

A stricter format that only accepts HH:mm:ss with no fractions of seconds or timezone.

date-time format

A stricter format that only accepts T as a separator and Z as the timezone: 2021-02-13T22:04:00Z

Fractions of seconds are allowed: 2021-02-13T22:04:00.000Z

uuid format

A stricter format that only allows lowercase characters.