Gathering detailed insights and metrics for ajv-formats
Gathering detailed insights and metrics for ajv-formats
Gathering detailed insights and metrics for ajv-formats
Gathering detailed insights and metrics for ajv-formats
@innoways/drip-form-plugin-formats
drip-form ajv formats插件
@jdfed/drip-form-plugin-formats
drip-form ajv formats插件
ajv-formats-draft2019
Plugin for AJV that adds support for some of string formats adding in the draft2019 JSON Schema.
@fastify/ajv-compiler
Build and manage the AJV instances for the fastify framework
npm install ajv-formats
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
191 Stars
109 Commits
37 Forks
5 Watching
3 Branches
10 Contributors
Updated on 26 Nov 2024
Minified
Minified + Gzipped
TypeScript (90.56%)
JavaScript (9.44%)
Cumulative downloads
Total Downloads
Last day
-1.1%
5,101,810
Compared to previous day
Last week
4.3%
26,724,166
Compared to previous week
Last month
13%
109,895,489
Compared to previous month
Last year
44.2%
1,010,637,127
Compared to previous year
JSON Schema formats for Ajv
1// ESM/TypeScript import 2import Ajv from "ajv" 3import addFormats from "ajv-formats" 4// Node.js require: 5const Ajv = require("ajv") 6const addFormats = require("ajv-formats") 7 8const ajv = new Ajv() 9addFormats(ajv)
The package defines these formats:
See regular expressions used for format validation and the sources that were used in formats.ts.
Please note: JSON Schema draft-07 also defines formats iri
, iri-reference
, idn-hostname
and idn-email
for URLs, hostnames and emails with international characters. These formats are available in ajv-formats-draft2019 plugin.
formatMaximum
/ formatMinimum
and formatExclusiveMaximum
/ formatExclusiveMinimum
These keywords allow to define minimum/maximum constraints when the format keyword defines ordering (compare
function in format definition).
These keywords are added to ajv instance when ajv-formats is used without options or with option keywords: true
.
These keywords apply only to strings. If the data is not a string, the validation succeeds.
The value of keywords formatMaximum
/formatMinimum
and formatExclusiveMaximum
/formatExclusiveMinimum
should be a string or $data reference. This value is the maximum (minimum) allowed value for the data to be valid as determined by format
keyword. If format
keyword is not present schema compilation will throw exception.
When these keyword are added, they also add comparison functions to formats "date"
, "time"
and "date-time"
. User-defined formats also can have comparison functions. See addFormat method.
1require("ajv-formats")(ajv) 2 3const schema = { 4 type: "string", 5 format: "date", 6 formatMinimum: "2016-02-06", 7 formatExclusiveMaximum: "2016-12-27", 8} 9 10const validDataList = ["2016-02-06", "2016-12-26"] 11 12const invalidDataList = ["2016-02-05", "2016-12-27", "abc"]
Options can be passed via the second parameter. Options value can be
1addFormats(ajv, ["date", "time"])
Please note: when ajv encounters an undefined format it throws exception (unless ajv instance was configured with strict: false
option). To allow specific undefined formats they have to be passed to ajv instance via formats
option with true
value:
1const ajv = new Ajv({formats: {date: true, time: true}}) // to ignore "date" and "time" formats in schemas.
"full"
) with optional list of format names and keywords
option to add additional format comparison keywords:1addFormats(ajv, {mode: "fast"})
or
1addFormats(ajv, {mode: "fast", formats: ["date", "time"], keywords: true})
In "fast"
mode the following formats are simplified: "date"
, "time"
, "date-time"
, "iso-time"
, "iso-date-time"
, "uri"
, "uri-reference"
, "email"
. For example, "date"
, "time"
and "date-time"
do not validate ranges in "fast"
mode, only string structure, and other formats have simplified regular expressions.
1npm install 2git submodule update --init 3npm test
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 8/20 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More