@oridune/epic-odm
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "@oridune/epic-odm", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Install 1 ODM and code once with any database driver.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Field = exports.TypeCast = exports.FieldValidation = void 0; | ||
const operators_1 = require("../operators"); | ||
const utils_1 = require("./utils"); | ||
@@ -46,3 +47,4 @@ const FieldValidation = (name, options) => async (value, payload, mode = "create") => { | ||
if (((options.nullable && value !== null) || !options.nullable) && | ||
value !== undefined) { | ||
value !== undefined && | ||
!(value instanceof operators_1.Operator)) { | ||
// Enum Validation | ||
@@ -55,12 +57,10 @@ if (options.choices instanceof Array) | ||
throw new Error(`The value '${value}' provided for field '${name}' does not match the pattern '${options.match}'!`); | ||
if (typeof value === "string") { | ||
if (typeof options.minLength === "number" && options.minLength >= 0) | ||
if (((_b = (((_a = value.toString) === null || _a === void 0 ? void 0 : _a.call(value)) || value)) === null || _b === void 0 ? void 0 : _b.length) < options.minLength) | ||
// Minimum Length Validation | ||
throw new Error(`Value length (${(_d = (((_c = value.toString) === null || _c === void 0 ? void 0 : _c.call(value)) || value)) === null || _d === void 0 ? void 0 : _d.length}) for field '${name}' is smaller than expected length which is ${options.minLength}!`); | ||
// Maximum Length Validation | ||
if (typeof options.length === "number" && options.length >= 0) | ||
if (((_f = (((_e = value.toString) === null || _e === void 0 ? void 0 : _e.call(value)) || value)) === null || _f === void 0 ? void 0 : _f.length) > options.length) | ||
throw new Error(`Value length (${(_h = (((_g = value.toString) === null || _g === void 0 ? void 0 : _g.call(value)) || value)) === null || _h === void 0 ? void 0 : _h.length}) for field '${name}' is greater than expected length which is ${options.length}!`); | ||
} | ||
if (typeof options.minLength === "number" && options.minLength >= 0) | ||
if (((_b = (((_a = value.toString) === null || _a === void 0 ? void 0 : _a.call(value)) || value)) === null || _b === void 0 ? void 0 : _b.length) < options.minLength) | ||
// Minimum Length Validation | ||
throw new Error(`Value length (${(_d = (((_c = value.toString) === null || _c === void 0 ? void 0 : _c.call(value)) || value)) === null || _d === void 0 ? void 0 : _d.length}) for field '${name}' is smaller than expected length which is ${options.minLength}!`); | ||
// Maximum Length Validation | ||
if (typeof options.length === "number" && options.length >= 0) | ||
if (((_f = (((_e = value.toString) === null || _e === void 0 ? void 0 : _e.call(value)) || value)) === null || _f === void 0 ? void 0 : _f.length) > options.length) | ||
throw new Error(`Value length (${(_h = (((_g = value.toString) === null || _g === void 0 ? void 0 : _g.call(value)) || value)) === null || _h === void 0 ? void 0 : _h.length}) for field '${name}' is greater than expected length which is ${options.length}!`); | ||
} | ||
@@ -67,0 +67,0 @@ return value; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123070