@kubernetes-models/validate
Advanced tools
Comparing version 0.0.0-20230407125710 to 0.0.0-20240401155416
@@ -1,2 +0,2 @@ | ||
export { register } from "./ajv"; | ||
export { validate } from "./validate"; | ||
export { formats, addFormats } from "./formats"; | ||
export { ValidateFunc, runValidateFunc } from "./validate"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validate = exports.register = void 0; | ||
var ajv_1 = require("./ajv.js"); | ||
Object.defineProperty(exports, "register", { enumerable: true, get: function () { return ajv_1.register; } }); | ||
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, "validate", { enumerable: true, get: function () { return validate_1.validate; } }); | ||
Object.defineProperty(exports, "runValidateFunc", { enumerable: true, get: function () { return validate_1.runValidateFunc; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,6 @@ | ||
export declare function validate(id: string, data: unknown): void; | ||
import type { ErrorObject } from "ajv"; | ||
export interface ValidateFunc<T> { | ||
(data: unknown): data is T; | ||
errors?: ErrorObject[] | null; | ||
} | ||
export declare function runValidateFunc<T>(fn: ValidateFunc<T>, data: unknown): asserts data is T; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validate = void 0; | ||
exports.runValidateFunc = void 0; | ||
const tslib_1 = require("tslib"); | ||
const ajv_1 = tslib_1.__importDefault(require("ajv")); | ||
const ajv_2 = require("./ajv.js"); | ||
const validation_error_1 = tslib_1.__importDefault(require("ajv/dist/runtime/validation_error")); | ||
function excludeNullableRefErrors(errors) { | ||
@@ -50,11 +49,18 @@ const result = []; | ||
} | ||
function validate(id, data) { | ||
if (!ajv_2.ajv.validate(id, data) && ajv_2.ajv.errors) { | ||
const errors = excludeNullableRefErrors(ajv_2.ajv.errors); | ||
const err = new ajv_1.default.ValidationError(errors); | ||
err.message = ajv_2.ajv.errorsText(errors); | ||
function generateErrorMessage(errors) { | ||
return errors | ||
.map((err) => `data${err.instancePath} ${err.message}`) | ||
.join(", "); | ||
} | ||
function runValidateFunc(fn, data) { | ||
if (!fn(data) && fn.errors) { | ||
const errors = excludeNullableRefErrors(fn.errors); | ||
if (!errors.length) | ||
return; | ||
const err = new validation_error_1.default(errors); | ||
err.message = generateErrorMessage(errors); | ||
throw err; | ||
} | ||
} | ||
exports.validate = validate; | ||
exports.runValidateFunc = runValidateFunc; | ||
//# sourceMappingURL=validate.js.map |
{ | ||
"name": "@kubernetes-models/validate", | ||
"version": "0.0.0-20230407125710", | ||
"version": "0.0.0-20240401155416", | ||
"main": "dist/index.js", | ||
@@ -9,5 +9,12 @@ "module": "dist/index.mjs", | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
".": { | ||
"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" | ||
} | ||
}, | ||
@@ -37,4 +44,6 @@ "description": "Validation library for Kubernetes models.", | ||
"dependencies": { | ||
"ajv": "^8.11.0", | ||
"ajv": "^8.12.0", | ||
"ajv-formats": "^2.1.1", | ||
"ajv-formats-draft2019": "^1.6.1", | ||
"is-cidr": "^4.0.0", | ||
"tslib": "^2.4.0" | ||
@@ -41,0 +50,0 @@ }, |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22094
52
287
5
1
+ Addedajv-formats-draft2019@^1.6.1
+ Addedis-cidr@^4.0.0
+ Addedajv-formats-draft2019@1.6.1(transitive)
+ Addedcidr-regex@3.1.1(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addeddiscontinuous-range@1.0.0(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedip-regex@4.3.0(transitive)
+ Addedis-cidr@4.0.2(transitive)
+ Addedmoo@0.5.2(transitive)
+ Addednearley@2.20.1(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedrailroad-diagrams@1.0.0(transitive)
+ Addedrandexp@0.4.6(transitive)
+ Addedret@0.1.15(transitive)
+ Addedschemes@1.4.0(transitive)
+ Addedsmtp-address-parser@1.1.0(transitive)
+ Addeduri-js@4.4.1(transitive)
Updatedajv@^8.12.0