Socket
Socket
Sign inDemoInstall

ajv-formats

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv-formats - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

.travis.yml

9

dist/index.js

@@ -8,16 +8,15 @@ "use strict";

const names = Object.keys(fs);
addFormats(names, fs, opts);
addFormats(names, fs);
}
else if (Array.isArray(opts)) {
addFormats(opts, formats_1.formats.full, "full");
addFormats(opts, formats_1.formats.full);
}
else {
addFormats(opts.formats, formats_1.formats[opts.mode], opts.mode);
addFormats(opts.formats, formats_1.formats[opts.mode]);
}
return ajv;
function addFormats(list, fs, mode) {
function addFormats(list, fs) {
for (const f of list) {
ajv.addFormat(f, fs[f]);
}
ajv._opts.format = mode;
}

@@ -24,0 +23,0 @@ };

@@ -1,7 +0,4 @@

import { Format, FormatMode } from "./formats";
import { Format } from "./formats";
export interface Ajv {
addFormat: (name: string, f: Format) => Ajv;
_opts: {
format: FormatMode | false;
};
}

@@ -8,0 +5,0 @@ export default interface AjvPlugin {

{
"name": "ajv-formats",
"version": "0.1.0",
"version": "0.2.0",
"description": "Format validation for Ajv v7 (WIP)",

@@ -12,3 +12,4 @@ "main": "dist/index.js",

"eslint": "eslint --ext .ts ./src/**/*",
"test": "npm run prettier:check && npm run eslint && npm run build"
"test": "jest",
"ci-test": "npm run prettier:check && npm run eslint && npm run build && npm run test"
},

@@ -15,0 +16,0 @@ "repository": {

# ajv-formats
Format validation for Ajv v7 (WIP)
[![Build Status](https://travis-ci.org/ajv-validator/ajv-formats.svg?branch=master)](https://travis-ci.org/ajv-validator/ajv-formats)
[![npm](https://img.shields.io/npm/v/ajv-formats.svg)](https://www.npmjs.com/package/ajv-formats)
[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)
[![GitHub Sponsors](https://img.shields.io/badge/$-sponsors-brightgreen)](https://github.com/sponsors/epoberezkin)

@@ -82,4 +82,4 @@ export type FormatMode = "fast" | "full"

// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
uri: /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,
"uri-reference": /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
"uri-reference": /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
"uri-template": URITEMPLATE,

@@ -86,0 +86,0 @@ url: URL,

@@ -24,19 +24,14 @@ import {

const names = Object.keys(fs) as FormatName[]
addFormats(names, fs, opts)
addFormats(names, fs)
} else if (Array.isArray(opts)) {
addFormats(opts, formats.full, "full")
addFormats(opts, formats.full)
} else {
addFormats(opts.formats, formats[opts.mode], opts.mode)
addFormats(opts.formats, formats[opts.mode])
}
return ajv
function addFormats(
list: FormatName[],
fs: DefinedFormats,
mode: FormatMode
) {
function addFormats(list: FormatName[], fs: DefinedFormats) {
for (const f of list) {
ajv.addFormat(f, fs[f])
}
ajv._opts.format = mode
}

@@ -43,0 +38,0 @@ }

// TODO move plugin interface either to ajv or a separate package
import {Format, FormatMode} from "./formats"
import {Format} from "./formats"
export interface Ajv {
addFormat: (name: string, f: Format) => Ajv
_opts: {
format: FormatMode | false
}
}

@@ -10,0 +7,0 @@

@@ -13,6 +13,8 @@ "use strict"

jsonSchemaTest(instances, {
description: `JSON-Schema Test Suite draft-07: ${instances.length} ajv instances with different options`,
description: `JSON-Schema Test Suite draft-07 + extras: ${instances.length} ajv instances with different options`,
suites: {
draft7:
"./JSON-Schema-Test-Suite/tests/draft7/optional/{format/*,ecmascript-regex}.json",
"draft-07 formats":
"./JSON-Schema-Test-Suite/tests/draft7/optional/format/*.json",
"draft-07 regex":
"./JSON-Schema-Test-Suite/tests/draft7/optional/ecmascript-regex.json",
extras: "./extras/{**/,}*.json",

@@ -19,0 +21,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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