@oridune/epic-odm
Advanced tools
Comparing version 1.1.7 to 1.1.8
{ | ||
"name": "@oridune/epic-odm", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "Install 1 ODM and code once with any database driver.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -26,5 +26,5 @@ import { GraphQLObjectType, GraphQLList } from "graphql"; | ||
/** Set minimum length */ | ||
minLength?: number; | ||
minLength?: number | (() => number); | ||
/** Set maximum length (Set null for unlimited length in SQL) */ | ||
length?: number | null; | ||
length?: number | null | (() => number | null); | ||
/** Is this field nullable? */ | ||
@@ -31,0 +31,0 @@ nullable?: boolean; |
@@ -59,10 +59,16 @@ "use strict"; | ||
throw new Error(`The value '${value}' provided for field '${name}' does not match the pattern '${options.match}'!`); | ||
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) | ||
const MinLength = typeof options.minLength === "function" | ||
? options.minLength() | ||
: options.minLength; | ||
if (typeof MinLength === "number" && 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) < 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}!`); | ||
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 ${MinLength}!`); | ||
const Length = typeof options.length === "function" | ||
? options.length() | ||
: options.length; | ||
// 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 Length === "number" && 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) > 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 ${Length}!`); | ||
} | ||
@@ -111,6 +117,9 @@ return value; | ||
typeof options.choices === "function") && | ||
options.length === undefined) { | ||
const Choices = options.choices instanceof Array ? options.choices : options.choices(); | ||
options.length = Math.max(...Choices.map((c) => c.toString().length)); | ||
} | ||
options.length === undefined) | ||
options.length = () => { | ||
const Choices = options.choices instanceof Array | ||
? options.choices | ||
: options.choices(); | ||
return Math.max(...Choices.map((c) => c.toString().length)); | ||
}; | ||
else if (options.type === Object && options.length === undefined) | ||
@@ -117,0 +126,0 @@ options.length = null; |
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
134541
2814