@bunt/input
Advanced tools
Comparing version 0.19.12 to 0.19.16
@@ -6,3 +6,3 @@ "use strict"; | ||
async function validate(type, value) { | ||
if (util_1.isFunction(type)) { | ||
if ((0, util_1.isFunction)(type)) { | ||
return type().validate(value); | ||
@@ -9,0 +9,0 @@ } |
@@ -9,3 +9,3 @@ "use strict"; | ||
validate(payload) { | ||
this.assert(util_1.isBoolean(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert((0, util_1.isBoolean)(payload), `Wrong payload: ${this.name} expected`, payload); | ||
return payload; | ||
@@ -12,0 +12,0 @@ }, |
@@ -9,3 +9,3 @@ "use strict"; | ||
validate(payload) { | ||
this.assert(util_1.isNumber(payload) || util_1.isString(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert((0, util_1.isNumber)(payload) || (0, util_1.isString)(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert(validateDateValue(payload), "Wrong date format", payload); | ||
@@ -12,0 +12,0 @@ return new Date(payload); |
@@ -25,3 +25,3 @@ "use strict"; | ||
validate(input) { | ||
this.assert(util_1.isString(input), "Wrong type", input); | ||
this.assert((0, util_1.isString)(input), "Wrong type", input); | ||
this.assert(!/^\d+$/.test(input), "Wrong value", input); | ||
@@ -28,0 +28,0 @@ this.assert(input in __classPrivateFieldGet(this, _Enum_value, "f"), "Wrong value", input); |
@@ -34,3 +34,3 @@ "use strict"; | ||
merge(from) { | ||
if (util_1.isInstanceOf(from, Fields)) { | ||
if ((0, util_1.isInstanceOf)(from, Fields)) { | ||
return new Fields(Object.assign({}, this.fields, from)); | ||
@@ -41,3 +41,3 @@ } | ||
async validate(payload) { | ||
this.assert(util_1.isObject(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert((0, util_1.isObject)(payload), `Wrong payload: ${this.name} expected`, payload); | ||
const entries = []; | ||
@@ -47,8 +47,8 @@ const validations = new Map(); | ||
try { | ||
const validationType = util_1.isFunction(type) ? type() : type; | ||
this.assert(util_1.isInstanceOf(validationType, TypeAbstract_1.TypeAbstract), `Wrong field: ${field}`, payload[field]); | ||
const validationType = (0, util_1.isFunction)(type) ? type() : type; | ||
this.assert((0, util_1.isInstanceOf)(validationType, TypeAbstract_1.TypeAbstract), `Wrong field: ${field}`, payload[field]); | ||
entries.push([field, await validationType.validate(payload[field])]); | ||
} | ||
catch (error) { | ||
if (util_1.isInstanceOf(error, Assertion_1.AssertionTypeError)) { | ||
if ((0, util_1.isInstanceOf)(error, Assertion_1.AssertionTypeError)) { | ||
validations.set(field, error.toSafeJSON()); | ||
@@ -59,3 +59,3 @@ continue; | ||
payload: payload[field], | ||
message: error.message, | ||
message: (0, util_1.toError)(error, "Unknown").message, | ||
type: "Unknown", | ||
@@ -66,5 +66,5 @@ }); | ||
if (validations.size > 0) { | ||
throw new Assertion_1.AssertionObjectError("Assertion failed", this, payload, util_1.entriesReverse([...validations.entries()])); | ||
throw new Assertion_1.AssertionObjectError("Assertion failed", this, payload, (0, util_1.entriesReverse)([...validations.entries()])); | ||
} | ||
return util_1.entriesReverse(entries); | ||
return (0, util_1.entriesReverse)(entries); | ||
} | ||
@@ -71,0 +71,0 @@ } |
@@ -9,3 +9,3 @@ "use strict"; | ||
validate(payload) { | ||
this.assert(util_1.isNumber(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert((0, util_1.isNumber)(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert(payload <= Number.MAX_SAFE_INTEGER && payload >= Number.MIN_SAFE_INTEGER, "Wrong payload range", payload); | ||
@@ -12,0 +12,0 @@ return payload; |
@@ -9,3 +9,3 @@ "use strict"; | ||
validate(payload) { | ||
this.assert(util_1.isNumber(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert((0, util_1.isNumber)(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert(Number.isSafeInteger(payload), "Wrong payload value", payload); | ||
@@ -12,0 +12,0 @@ return payload; |
@@ -9,3 +9,3 @@ "use strict"; | ||
validate(payload) { | ||
this.assert(util_1.isString(payload), "Wrong payload", payload); | ||
this.assert((0, util_1.isString)(payload), "Wrong payload", payload); | ||
return JSON.parse(payload); | ||
@@ -12,0 +12,0 @@ }, |
@@ -9,3 +9,3 @@ "use strict"; | ||
async validate(payload) { | ||
this.assert(util_1.isArray(payload), `Wrong payload: ${this.type.name}[] expected`, payload); | ||
this.assert((0, util_1.isArray)(payload), `Wrong payload: ${this.type.name}[] expected`, payload); | ||
let index = 0; | ||
@@ -19,3 +19,3 @@ const result = []; | ||
catch (error) { | ||
if (util_1.isInstanceOf(error, Assertion_1.AssertionTypeError)) { | ||
if ((0, util_1.isInstanceOf)(error, Assertion_1.AssertionTypeError)) { | ||
validations.add({ index, ...error.toSafeJSON() }); | ||
@@ -27,3 +27,3 @@ } | ||
payload: item, | ||
message: error.message, | ||
message: (0, util_1.toError)(error, "Unknown").message, | ||
type: this.type.name, | ||
@@ -30,0 +30,0 @@ }); |
@@ -25,4 +25,4 @@ "use strict"; | ||
validate(payload) { | ||
if (util_1.isNull(payload) || util_1.isUndefined(payload)) { | ||
if (util_1.isFunction(__classPrivateFieldGet(this, _NonNull_defaultValue, "f"))) { | ||
if ((0, util_1.isNull)(payload) || (0, util_1.isUndefined)(payload)) { | ||
if ((0, util_1.isFunction)(__classPrivateFieldGet(this, _NonNull_defaultValue, "f"))) { | ||
return __classPrivateFieldGet(this, _NonNull_defaultValue, "f").call(this); | ||
@@ -29,0 +29,0 @@ } |
@@ -8,3 +8,3 @@ "use strict"; | ||
validate(payload) { | ||
if (util_1.isNull(payload) || util_1.isUndefined(payload)) { | ||
if ((0, util_1.isNull)(payload) || (0, util_1.isUndefined)(payload)) { | ||
return undefined; | ||
@@ -11,0 +11,0 @@ } |
@@ -9,4 +9,4 @@ "use strict"; | ||
validate(payload) { | ||
this.assert(util_1.isNumber(payload) || util_1.isString(payload), `Wrong payload: ${this.name} expected`, payload); | ||
const value = util_1.isNumber(payload) ? payload : parseInt(payload, 10); | ||
this.assert((0, util_1.isNumber)(payload) || (0, util_1.isString)(payload), `Wrong payload: ${this.name} expected`, payload); | ||
const value = (0, util_1.isNumber)(payload) ? payload : parseInt(payload, 10); | ||
this.assert(!isNaN(value) && Number.isSafeInteger(value), `Wrong payload: ${this.name} expected`, payload); | ||
@@ -13,0 +13,0 @@ return value; |
@@ -9,3 +9,3 @@ "use strict"; | ||
validate(payload) { | ||
this.assert(util_1.isString(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert((0, util_1.isString)(payload), `Wrong payload: ${this.name} expected`, payload); | ||
return payload; | ||
@@ -12,0 +12,0 @@ }, |
@@ -10,3 +10,3 @@ "use strict"; | ||
validate(payload) { | ||
this.assert(util_1.isNumber(payload) || util_1.isString(payload), `Wrong payload type`, payload); | ||
this.assert((0, util_1.isNumber)(payload) || (0, util_1.isString)(payload), `Wrong payload type`, payload); | ||
return Int_1.Int.validate(+payload); | ||
@@ -13,0 +13,0 @@ }, |
@@ -10,3 +10,3 @@ "use strict"; | ||
validate(payload) { | ||
this.assert(util_1.isString(payload) && RE.test(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert((0, util_1.isString)(payload) && RE.test(payload), `Wrong payload: ${this.name} expected`, payload); | ||
return payload; | ||
@@ -13,0 +13,0 @@ }, |
@@ -24,8 +24,8 @@ "use strict"; | ||
const { min, max } = options; | ||
this.assert(util_1.isUndefined(min) || min > -1, `Wrong ${this.name} min size`, min); | ||
this.assert(util_1.isUndefined(max) || max < Number.MAX_SAFE_INTEGER, `Wrong ${this.name} max size`, max); | ||
this.assert((0, util_1.isUndefined)(min) || min > -1, `Wrong ${this.name} min size`, min); | ||
this.assert((0, util_1.isUndefined)(max) || max < Number.MAX_SAFE_INTEGER, `Wrong ${this.name} max size`, max); | ||
} | ||
validate(payload) { | ||
const { min, max } = __classPrivateFieldGet(this, _Varchar_options, "f"); | ||
this.assert(util_1.isString(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert((0, util_1.isString)(payload), `Wrong payload: ${this.name} expected`, payload); | ||
this.assert(!min || payload.length >= min, `Wrong payload: ${this.name} min ${min}`, payload); | ||
@@ -32,0 +32,0 @@ this.assert(!max || payload.length <= max, `Wrong payload: ${this.name} min ${min}`, payload); |
@@ -10,3 +10,3 @@ "use strict"; | ||
assert(expr, message, payload) { | ||
Assertion_1.assert(expr, this, message, payload); | ||
(0, Assertion_1.assert)(expr, this, message, payload); | ||
} | ||
@@ -13,0 +13,0 @@ } |
{ | ||
"name": "@bunt/input", | ||
"version": "0.19.12", | ||
"version": "0.19.16", | ||
"keywords": [ | ||
@@ -29,6 +29,6 @@ "typescript" | ||
"dependencies": { | ||
"@bunt/util": "^0.19.12" | ||
"@bunt/util": "^0.19.16" | ||
}, | ||
"license": "MIT", | ||
"gitHead": "af2ad3c8c543ddc526a1333910f5487d80c84d78" | ||
"gitHead": "4d9fc4fc6414228f9cfb275f9cead9a53bca76c0" | ||
} |
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
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
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
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
56692
Updated@bunt/util@^0.19.16