Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kubernetes-models/validate

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kubernetes-models/validate - npm Package Compare versions

Comparing version 3.1.2 to 4.0.0

dist/formats.d.ts

9

dist/index.d.ts

@@ -1,7 +0,2 @@

import { AnySchema } from 'ajv';
declare function register(id: string, schema: AnySchema): void;
declare function validate(id: string, data: unknown): void;
export { register, validate };
export { formats } from "./formats";
export { type ValidateFunc, runValidateFunc } from "./validate";

@@ -1,81 +0,8 @@

'use strict';
var Ajv = require('ajv');
var addFormats = require('ajv-formats');
var addFormatsDraft2019 = require('ajv-formats-draft2019');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
var addFormats__default = /*#__PURE__*/_interopDefault(addFormats);
var addFormatsDraft2019__default = /*#__PURE__*/_interopDefault(addFormatsDraft2019);
// src/ajv.ts
var draft2019_default = addFormatsDraft2019__default.default;
// src/ajv.ts
var rBase64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
var rSignedNumber = /[+-]?(?:\d+|\d+\.\d+|\d+\.|\.\d+)/;
var rBinarySI = /[KMGTPE]i/;
var rDecimalSI = /(?:[YZEPTGMkhdcmunpfazy]|da)/;
var rDecimalExponent = new RegExp(`[eE]${rSignedNumber.source}`);
var rQuantitySuffix = new RegExp(
`(?:${rBinarySI.source}|${rDecimalSI.source}|${rDecimalExponent.source})?`
);
var rQuantity = new RegExp(
`^${rSignedNumber.source}${rQuantitySuffix.source}$`
);
var ajv = new Ajv__default.default({
strictTypes: false,
allErrors: true,
verbose: true
});
addFormats__default.default(ajv);
draft2019_default(ajv);
function register(id, schema) {
if (!ajv.getSchema(id)) {
ajv.addSchema(schema, id);
}
}
ajv.addFormat("byte", {
type: "string",
validate: (value) => rBase64.test(value)
});
ajv.addFormat("quantity", {
type: "string",
validate: rQuantity
});
ajv.addFormat("string", {
type: "string",
validate: (value) => typeof value === "string"
});
function excludeNullableRefErrors(errors) {
const result = [];
const schemaPathsToExclude = /* @__PURE__ */ new Set();
for (const err of errors) {
if (err.keyword === "oneOf") {
const nullTypeIndex = err.schema?.findIndex(
(x) => x.type === "null"
);
if (nullTypeIndex > -1) {
schemaPathsToExclude.add(`${err.schemaPath}/${nullTypeIndex}/type`);
continue;
}
}
result.push(err);
}
return result.filter((x) => !schemaPathsToExclude.has(x.schemaPath));
}
function validate(id, data) {
if (!ajv.validate(id, data) && ajv.errors) {
const errors = excludeNullableRefErrors(ajv.errors);
const err = new Ajv__default.default.ValidationError(errors);
err.message = ajv.errorsText(errors);
throw err;
}
}
exports.register = register;
exports.validate = validate;
//# sourceMappingURL=out.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.runValidateFunc = exports.formats = void 0;
var formats_1 = require("./formats.js");
Object.defineProperty(exports, "formats", { enumerable: true, get: function () { return formats_1.formats; } });
var validate_1 = require("./validate.js");
Object.defineProperty(exports, "runValidateFunc", { enumerable: true, get: function () { return validate_1.runValidateFunc; } });
//# sourceMappingURL=index.js.map
{
"name": "@kubernetes-models/validate",
"version": "3.1.2",
"version": "4.0.0",
"main": "dist/index.js",

@@ -9,10 +9,12 @@ "module": "dist/index.mjs",

"exports": {
"node": {
"import": "./dist/index.node.mjs",
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"require": "./dist/index.js"
"./runtime/*": {
"types": "./dist/runtime/*.d.ts",
"import": "./dist/runtime/*.mjs",
"require": "./dist/runtime/*.js"
}
},

@@ -45,12 +47,17 @@ "description": "Validation library for Kubernetes models.",

"ajv-formats-draft2019": "^1.6.1",
"ajv-i18n": "^4.2.0",
"is-cidr": "^4.0.0",
"tslib": "^2.4.0"
},
"devDependencies": {
"tsup": "^8.1.0",
"tsc-multi": "^0.6.1",
"typescript": "^4.8.4",
"vitest": "^0.29.8"
},
"optionalDependencies": {
"re2-wasm": "^1.0.2"
},
"scripts": {
"build": "tsup"
"build": "tsc-multi --config ../../tsc-multi.json"
}
}

Sorry, the diff of this file is not supported yet

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