tv4-formats (v3.0.6) provides common JSON Schema string format constraints as tv4 validator callbacks. It is a plug-in for the tv4 JSON Schema validator. Supports formats: credit-card-number, date, date-time, duration, time-offset, email, guid, uri, url. Last updated in 2020, no active development. Alternative is ajv-formats for the AJV validator.
npm install tv4-formatsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to install and use tv4-formats with tv4 to validate a date format string.
Use require('tv4-formats') default export directly (no .addFormat methods on the export).Use alternative library like ajv-formats if you need those formats.
Do not rely solely on this library for credit card validation; use a dedicated service.
Replace tv4 and tv4-formats with AJV and ajv-formats for active maintenance and broader format support.
Ensure you are using tv4-formats v3 and do: const formats = require('tv4-formats'); tv4.addFormat(formats);Run: npm install --save tv4 tv4-formats
Call tv4.addFormat(require('tv4-formats')); before validation.