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 0.0.0-20240402180946 to 0.0.0-20240608085410

dist/index.node.mjs

9

dist/index.d.ts

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

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

@@ -1,9 +0,81 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.runValidateFunc = exports.addFormats = exports.formats = void 0;
var formats_1 = require("./formats.js");
Object.defineProperty(exports, "formats", { enumerable: true, get: function () { return formats_1.formats; } });
Object.defineProperty(exports, "addFormats", { enumerable: true, get: function () { return formats_1.addFormats; } });
var validate_1 = require("./validate.js");
Object.defineProperty(exports, "runValidateFunc", { enumerable: true, get: function () { return validate_1.runValidateFunc; } });
'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
//# sourceMappingURL=index.js.map
{
"name": "@kubernetes-models/validate",
"version": "0.0.0-20240402180946",
"version": "0.0.0-20240608085410",
"main": "dist/index.js",

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

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

@@ -47,7 +45,6 @@ "description": "Validation library for Kubernetes models.",

"ajv-formats-draft2019": "^1.6.1",
"is-cidr": "^4.0.0",
"tslib": "^2.4.0"
},
"devDependencies": {
"tsc-multi": "^0.6.1",
"tsup": "^8.1.0",
"typescript": "^4.8.4",

@@ -57,4 +54,4 @@ "vitest": "^0.29.8"

"scripts": {
"build": "tsc-multi --config ../../tsc-multi.json"
"build": "tsup"
}
}

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