Socket
Socket
Sign inDemoInstall

@vitrical/utils

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitrical/utils - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

141

api.js
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isApiError = exports.request = exports.requestImplementation = exports.ApiError = void 0;
var superagent_1 = __importDefault(require("superagent"));
var validation_1 = require("./validation");
var ApiError = (function (_super) {
__extends(ApiError, _super);
function ApiError() {
return _super !== null && _super.apply(this, arguments) || this;
const superagent_1 = __importDefault(require("superagent"));
const validation_1 = require("./validation");
class ApiError extends Error {
}
exports.ApiError = ApiError;
const requestImplementation = (agent) => async (baseURL, key, method, url, options) => {
const req = agent(method, baseURL + url);
req.set('Key', key);
if (options?.body) {
req.set('Content-Type', 'application/json');
}
return ApiError;
}(Error));
exports.ApiError = ApiError;
var requestImplementation = function (agent) {
return function (baseURL, key, method, url, options) { return __awaiter(void 0, void 0, void 0, function () {
var req, res, returnData, error;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
req = agent(method, baseURL + url);
req.set('Key', key);
if (options === null || options === void 0 ? void 0 : options.body) {
req.set('Content-Type', 'application/json');
}
if (options === null || options === void 0 ? void 0 : options.headers) {
req.set(options.headers);
}
if (options === null || options === void 0 ? void 0 : options.query) {
req.query(options.query);
}
if (options === null || options === void 0 ? void 0 : options.body) {
req.send(options.body);
}
return [4, req];
case 1:
res = _b.sent();
returnData = {
status: res.status,
body: res.body,
headers: res.headers
};
if (res.status !== 200) {
error = new ApiError(((_a = res.body) === null || _a === void 0 ? void 0 : _a.msg) || "Request failed with status code ".concat(res.status));
error.status = returnData.status;
error.body = returnData.body;
error.headers = returnData.headers;
throw error;
}
return [2, returnData];
}
});
}); };
if (options?.headers) {
req.set(options.headers);
}
if (options?.query) {
req.query(options.query);
}
if (options?.body) {
req.send(options.body);
}
const res = await req;
const returnData = {
status: res.status,
body: res.body,
headers: res.headers,
};
if (res.status !== 200) {
const error = new ApiError(res.body?.msg || `Request failed with status code ${res.status}`);
error.status = returnData.status;
error.body = returnData.body;
error.headers = returnData.headers;
throw error;
}
return returnData;
};
exports.requestImplementation = requestImplementation;
var request = function (baseURL, key, method, url, options) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
return [2, (0, exports.requestImplementation)(superagent_1["default"])(baseURL, key, method, url, options)];
}); }); };
const request = async (baseURL, key, method, url, options) => (0, exports.requestImplementation)(superagent_1.default)(baseURL, key, method, url, options);
exports.request = request;
var isApiError = function (err) {
const isApiError = (err) => {
if (typeof err !== 'object' || !err)

@@ -116,0 +47,0 @@ return false;

@@ -1,5 +0,5 @@

import { Request, Response, NextFunction } from 'express';
import type { Request, Response, NextFunction } from 'express';
import { ValidateObjectOptions } from './validation';
export declare const handleExpressError: (err: unknown, _req: Request, res: Response, next: NextFunction) => void;
export declare const requireApiKey: (apiKey: string) => (req: Request, res: Response, next: NextFunction) => void;
export declare const validateBody: (schema: ValidateObjectOptions) => (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
export declare const validateBody: (schema: ValidateObjectOptions) => (req: Request, res: Response, next: NextFunction) => void;
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateBody = exports.requireApiKey = exports.handleExpressError = void 0;
var validation_1 = require("./validation");
var api_1 = require("./api");
var handleExpressError = function (err, _req, res, next) {
const validation_1 = require("./validation");
const api_1 = require("./api");
const handleExpressError = (err, _req, res, next) => {
if (!err)

@@ -14,3 +14,3 @@ return next();

msg: err.message,
body: err.body
body: err.body,
});

@@ -23,3 +23,3 @@ return;

res.status(500).send({
msg: err.message + ''
msg: err.message + '',
});

@@ -31,25 +31,23 @@ return;

msg: 'Unknown Error',
err: err
err,
});
};
exports.handleExpressError = handleExpressError;
var requireApiKey = function (apiKey) {
return function (req, res, next) {
try {
if (!apiKey)
console.error('Missing apiKey variable');
if (req.headers['key'] !== apiKey) {
res.status(403).send({ msg: 'Invalid API Key' });
return;
}
return next();
const requireApiKey = (apiKey) => (req, res, next) => {
try {
if (!apiKey)
console.error('Missing apiKey variable');
if (req.headers['key'] !== apiKey) {
res.status(403).send({ msg: 'Invalid API Key' });
return;
}
catch (err) {
next(err);
}
};
return next();
}
catch (err) {
next(err);
}
};
exports.requireApiKey = requireApiKey;
var validateBody = function (schema) { return function (req, res, next) {
var errors = (0, validation_1.validateObject)(schema, req.body);
const validateBody = (schema) => (req, res, next) => {
const errors = (0, validation_1.validateObject)(schema, req.body);
if (errors.length === 0) {

@@ -59,8 +57,8 @@ next();

else {
return res.status(400).send({
msg: "Errors present in the request body:\n ".concat(errors.reduce(function (a, b) { return "".concat(a, "\n ").concat(b); }))
res.status(400).send({
msg: `Errors present in the request body:\n ${errors.reduce((a, b) => `${a}\n ${b}`)}`,
});
}
}; };
};
exports.validateBody = validateBody;
//# sourceMappingURL=express.js.map

@@ -16,3 +16,3 @@ "use strict";

};
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./api"), exports);

@@ -19,0 +19,0 @@ __exportStar(require("./jwt"), exports);

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeToken = exports.detokenize = exports.tokenize = void 0;
var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
var tokenize = function (obj, key, options) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, new Promise(function (resolve, reject) {
jsonwebtoken_1["default"].sign(obj, key, __assign({ algorithm: 'RS256', expiresIn: '30m' }, (options || {})), function (err, token) {
if (err)
return reject(err);
if (!token)
return reject(new Error('No token provided'));
resolve(token);
});
})];
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
const tokenize = async (obj, key, options) => new Promise((resolve, reject) => {
jsonwebtoken_1.default.sign(obj, key, { algorithm: 'RS256', expiresIn: '30m', ...(options || {}) }, (err, token) => {
if (err)
return reject(err);
if (!token)
return reject(new Error('No token provided'));
resolve(token);
});
}); };
});
exports.tokenize = tokenize;
var detokenize = function (token, key, options) {
return new Promise(function (resolve, reject) {
jsonwebtoken_1["default"].verify(token, key, __assign({ algorithms: ['RS256'] }, options), function (err, decoded) {
if (err)
return reject(err);
if (!decoded)
return reject(new Error('No token provided'));
if (typeof decoded === 'string')
return reject(new Error('Invalid decode result ( string )'));
resolve(decoded);
});
const detokenize = (token, key, options) => new Promise((resolve, reject) => {
jsonwebtoken_1.default.verify(token, key, { algorithms: ['RS256'], ...options }, (err, decoded) => {
if (err)
return reject(err);
if (!decoded)
return reject(new Error('No token provided'));
if (typeof decoded === 'string')
return reject(new Error('Invalid decode result ( string )'));
resolve(decoded);
});
};
});
exports.detokenize = detokenize;
var decodeToken = function (token, options) {
var decoded = jsonwebtoken_1["default"].decode(token, options);
const decodeToken = (token, options) => {
const decoded = jsonwebtoken_1.default.decode(token, options);
if (decoded === null) {

@@ -86,0 +33,0 @@ throw new Error('Cannot decode the token');

{
"name": "@vitrical/utils",
"version": "1.1.1",
"version": "1.1.2",
"description": "Collection of useful functions and typings",

@@ -5,0 +5,0 @@ "main": "index.js",

{
"compileOnSave": true,
"compilerOptions": {
"allowJs": false,
"checkJs": false,
"strict": true,
"alwaysStrict": true,
"target": "ES2020",
"module": "commonjs",
"lib": ["es2017", "es7", "es6", "dom"],
"moduleResolution": "node",
"skipLibCheck": true,
"lib": ["es2020"],
"declaration": true,
"outDir": "dist",
"strictPropertyInitialization": false,
"strict": true,
"noImplicitAny": true,

@@ -15,3 +20,9 @@ "removeComments": true,

"allowSyntheticDefaultImports": true,
"esModuleInterop": true
"esModuleInterop": true,
"types": ["node"],
"forceConsistentCasingInFileNames": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"importsNotUsedAsValues": "error",
"noEmitOnError": true
},

@@ -18,0 +29,0 @@ "include": ["**/*.ts"],

"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
exports.objectMatchesSchema = exports.validateObject = exports.isValidationType = exports.getSeason = exports.capitalize = exports.isValidNAPhoneNumber = exports.formatPhoneNumber = exports.isValidEmail = exports.removeSpaces = exports.removeSpecialCharacters = exports.objectHasProperty = void 0;
var objectHasProperty = function (obj, property) {
const objectHasProperty = (obj, property) => {
return !!obj && typeof obj === 'object' && property in obj;
};
exports.objectHasProperty = objectHasProperty;
var removeSpecialCharacters = function (string) {
const removeSpecialCharacters = (string) => {
return string.replace(/[^a-zA-Z0-9 ]/g, '');
};
exports.removeSpecialCharacters = removeSpecialCharacters;
var removeSpaces = function (string) {
const removeSpaces = (string) => {
return string.replace(/\s+/g, '');
};
exports.removeSpaces = removeSpaces;
var isValidEmail = function (email) {
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const isValidEmail = (email) => {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
};
exports.isValidEmail = isValidEmail;
var formatPhoneNumber = function (phone) {
var cleaned = phone.replace(/\D/g, '');
var match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/);
const formatPhoneNumber = (phone) => {
const cleaned = phone.replace(/\D/g, '');
const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/);
if (match) {

@@ -39,16 +30,14 @@ return '(' + match[1] + ') ' + match[2] + '-' + match[3];

exports.formatPhoneNumber = formatPhoneNumber;
var isValidNAPhoneNumber = function (str) {
return /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im.test(str);
};
const isValidNAPhoneNumber = (str) => /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im.test(str);
exports.isValidNAPhoneNumber = isValidNAPhoneNumber;
var capitalize = function (word) {
const capitalize = (word) => {
return word
.split('')
.map(function (l, i) { return (i === 0 ? l.toUpperCase() : l); })
.map((l, i) => (i === 0 ? l.toUpperCase() : l))
.join('');
};
exports.capitalize = capitalize;
var getSeason = function (date) {
var month = date.getMonth() + 1;
var season = 'winter';
const getSeason = (date) => {
const month = date.getMonth() + 1;
let season = 'winter';
if (month > 3 && month < 6) {

@@ -66,3 +55,3 @@ season = 'spring';

exports.getSeason = getSeason;
var isValidationType = function (validationType, value) {
const isValidationType = (validationType, value) => {
switch (validationType) {

@@ -78,3 +67,3 @@ case 'array':

case 'array[]':
if (!Array.isArray(value) || value.some(function (v) { return !Array.isArray(v); }))
if (!Array.isArray(value) || value.some((v) => !Array.isArray(v)))
return false;

@@ -87,3 +76,3 @@ break;

case 'bigint[]':
if (!Array.isArray(value) || value.some(function (v) { return typeof v !== 'bigint'; }))
if (!Array.isArray(value) || value.some((v) => typeof v !== 'bigint'))
return false;

@@ -96,3 +85,3 @@ break;

case 'boolean[]':
if (!Array.isArray(value) || value.some(function (v) { return typeof v !== 'boolean'; }))
if (!Array.isArray(value) || value.some((v) => typeof v !== 'boolean'))
return false;

@@ -105,3 +94,3 @@ break;

case 'number[]':
if (!Array.isArray(value) || value.some(function (v) { return typeof v !== 'number'; }))
if (!Array.isArray(value) || value.some((v) => typeof v !== 'number'))
return false;

@@ -114,3 +103,3 @@ break;

case 'object[]':
if (!Array.isArray(value) || value.some(function (v) { return typeof v !== 'object'; }))
if (!Array.isArray(value) || value.some((v) => typeof v !== 'object'))
return false;

@@ -123,3 +112,3 @@ break;

case 'string[]':
if (!Array.isArray(value) || value.some(function (v) { return typeof v !== 'string'; }))
if (!Array.isArray(value) || value.some((v) => typeof v !== 'string'))
return false;

@@ -136,29 +125,28 @@ break;

function validateObject(schema, object) {
var bodyErrors = Object.keys(object)
.map(function (key) {
const bodyErrors = Object.keys(object)
.map((key) => {
if (!(key in schema)) {
return "Unexpected property \"".concat(key, ": ").concat(object[key], "\"");
return `Unexpected property "${key}: ${object[key]}"`;
}
return null;
})
.filter(function (i) { return !!i; });
var extraErrors = [];
var schemaErrors = Object.entries(schema)
.map(function (_a) {
var key = _a[0], validationSchema = _a[1];
var value = object[key];
.filter((i) => !!i);
const extraErrors = [];
const schemaErrors = Object.entries(schema)
.map(([key, validationSchema]) => {
const value = object[key];
if (typeof validationSchema === 'object' && !Array.isArray(validationSchema)) {
if (typeof value === 'undefined') {
return "Expected property \"".concat(key, ": typeof object\" does not exist on object");
return `Expected property "${key}: typeof object" does not exist on object`;
}
if (typeof value !== 'object' || Array.isArray(value)) {
return "Expected object but got ".concat(typeof value, " ").concat(value, " from property \"").concat(key, "\"");
return `Expected object but got ${typeof value} ${value} from property "${key}"`;
}
var foundErrors = validateObject(validationSchema, value);
const foundErrors = validateObject(validationSchema, value);
if (foundErrors.length !== 0) {
extraErrors.push.apply(extraErrors, foundErrors);
extraErrors.push(...foundErrors);
}
return null;
}
var validationType = typeof validationSchema === 'string' ? validationSchema : validationSchema[0];
const validationType = typeof validationSchema === 'string' ? validationSchema : validationSchema[0];
if (['number?', 'string?', 'array?', 'bigint?', 'boolean?', 'object?'].includes(validationType) &&

@@ -169,20 +157,20 @@ value === undefined) {

if (!(key in object)) {
return "Expected property \"".concat(key, ": typeof ").concat(schema[key], "\" does not exist on object");
return `Expected property "${key}: typeof ${schema[key]}" does not exist on object`;
}
if (!(0, exports.isValidationType)(validationType, value)) {
return "Expected ".concat(validationType, " but got ").concat(typeof value, " ").concat(value, " from property \"").concat(key, "\"");
return `Expected ${validationType} but got ${typeof value} ${value} from property "${key}"`;
}
if (typeof validationSchema !== 'string') {
var validationMin = validationSchema[1];
var validationMax = validationSchema[2];
const validationMin = validationSchema[1];
const validationMax = validationSchema[2];
if (typeof value === 'string' &&
(value.length < validationMin || value.length > validationMax)) {
return "Body property \"".concat(key, "\" must be within ").concat(validationMin, "-").concat(validationMax, " characters but recieved ").concat(value.length);
return `Body property "${key}" must be within ${validationMin}-${validationMax} characters but recieved ${value.length}`;
}
if (Array.isArray(value) &&
(value.length < validationMin || value.length > validationMax)) {
return "Body property \"".concat(key, "\" must be within ").concat(validationMin, "-").concat(validationMax, " length but got ").concat(value.length);
return `Body property "${key}" must be within ${validationMin}-${validationMax} length but got ${value.length}`;
}
if (typeof value === 'number' && (value < validationMin || value > validationMax)) {
return "Body property \"".concat(key, "\" must be within the range ").concat(validationMin, "-").concat(validationMax, " but got ").concat(value);
return `Body property "${key}" must be within the range ${validationMin}-${validationMax} but got ${value}`;
}

@@ -192,4 +180,4 @@ }

})
.filter(function (i) { return !!i; });
var errors = __spreadArray(__spreadArray(__spreadArray([], bodyErrors, true), schemaErrors, true), extraErrors, true);
.filter((i) => !!i);
const errors = [...bodyErrors, ...schemaErrors, ...extraErrors];
return errors;

@@ -199,5 +187,5 @@ }

function objectMatchesSchema(schema, data) {
var errors = validateObject(schema, data);
const errors = validateObject(schema, data);
if (errors.length !== 0) {
throw new Error("Object does not match what is expected\n ".concat(errors.reduce(function (a, b) { return "".concat(a, "\n ").concat(b); })));
throw new Error(`Object does not match what is expected\n ${errors.reduce((a, b) => `${a}\n ${b}`)}`);
}

@@ -204,0 +192,0 @@ return true;

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

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