@aomex/core
Advanced tools
Comparing version 1.0.1 to 1.0.2
# @aomex/core | ||
## 1.0.2 | ||
### Patch Changes | ||
- Updated dependencies []: | ||
- @aomex/internal-tools@1.0.2 | ||
## 1.0.1 | ||
@@ -4,0 +11,0 @@ |
@@ -33,4 +33,3 @@ // src/i18n/i18n-format.ts | ||
sub = sub[k]; | ||
if (!sub) | ||
break; | ||
if (!sub) break; | ||
} | ||
@@ -88,7 +87,5 @@ } | ||
Object.entries(override).forEach(([key, value]) => { | ||
if (value === void 0) | ||
return; | ||
if (value === void 0) return; | ||
const origin = data[key]; | ||
if (!origin) | ||
return; | ||
if (!origin) return; | ||
if (typeof value === "string" || this.isMessageObject(value)) { | ||
@@ -314,4 +311,3 @@ data[key] = value; | ||
const longestLengthOfPoint = toArray(point).map((p) => this.points[p]).filter(Boolean).sort((a, b) => b - a)[0]; | ||
if (!longestLengthOfPoint) | ||
return this; | ||
if (!longestLengthOfPoint) return this; | ||
const middlewareList = this.middlewareList.slice(longestLengthOfPoint); | ||
@@ -518,8 +514,5 @@ return new this.SubClass(middlewareList); | ||
isEmpty(value) { | ||
if (value !== "" && super.isEmpty(value)) | ||
return true; | ||
if (typeof value !== "string") | ||
return false; | ||
if (value === "" || this.getTrimValue(value) === "") | ||
return true; | ||
if (value !== "" && super.isEmpty(value)) return true; | ||
if (typeof value !== "string") return false; | ||
if (value === "" || this.getTrimValue(value) === "") return true; | ||
return false; | ||
@@ -715,4 +708,3 @@ } | ||
); | ||
if (error.errors.length) | ||
return error; | ||
if (error.errors.length) return error; | ||
} | ||
@@ -857,24 +849,23 @@ return magistrate.ok(items); | ||
if (!Buffer.isBuffer(value)) { | ||
loop: | ||
for (const encoding of fromEncodings) { | ||
switch (encoding) { | ||
case "hex": | ||
if (typeof value === "string" && hexReg.test(value)) { | ||
try { | ||
buffer = Buffer.from(value.replace(/^0x/i, ""), "hex"); | ||
break loop; | ||
} catch { | ||
} | ||
loop: for (const encoding of fromEncodings) { | ||
switch (encoding) { | ||
case "hex": | ||
if (typeof value === "string" && hexReg.test(value)) { | ||
try { | ||
buffer = Buffer.from(value.replace(/^0x/i, ""), "hex"); | ||
break loop; | ||
} catch { | ||
} | ||
break; | ||
case "base64": | ||
if (typeof value === "string" && base64Reg.test(value)) { | ||
try { | ||
buffer = Buffer.from(value, "base64"); | ||
break loop; | ||
} catch { | ||
} | ||
} | ||
break; | ||
case "base64": | ||
if (typeof value === "string" && base64Reg.test(value)) { | ||
try { | ||
buffer = Buffer.from(value, "base64"); | ||
break loop; | ||
} catch { | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} else { | ||
@@ -939,12 +930,8 @@ buffer = value; | ||
const { parseFromTimestamp } = this.config; | ||
if (value instanceof Date) | ||
return value; | ||
if (typeof value === "string") | ||
return new Date(value); | ||
if (value instanceof Date) return value; | ||
if (typeof value === "string") return new Date(value); | ||
if (parseFromTimestamp && typeof value === "number") { | ||
const timestamp = value.toString(); | ||
if (timestamp.length === 10) | ||
return new Date(Number(value + "000")); | ||
if (timestamp.length === 13) | ||
return new Date(value); | ||
if (timestamp.length === 10) return new Date(Number(value + "000")); | ||
if (timestamp.length === 13) return new Date(value); | ||
if (timestamp.length === 14 && unixTimeWithMS.test(timestamp)) { | ||
@@ -1010,4 +997,3 @@ return new Date(Number(timestamp.replace(".", ""))); | ||
const { ranges, strict } = this.config; | ||
if (ranges.includes(value)) | ||
return magistrate.ok(value); | ||
if (ranges.includes(value)) return magistrate.ok(value); | ||
if (!strict && typeof value === "string") { | ||
@@ -1019,4 +1005,3 @@ const num = Number(value); | ||
); | ||
if (matched) | ||
return magistrate.ok(matched); | ||
if (matched) return magistrate.ok(matched); | ||
} | ||
@@ -1217,4 +1202,3 @@ } | ||
); | ||
if (error.errors.length) | ||
return error; | ||
if (error.errors.length) return error; | ||
} else { | ||
@@ -1263,4 +1247,3 @@ Object.assign(obj, origin); | ||
const result = await validator.validate(value, key, label); | ||
if (magistrate.noError(result)) | ||
return result; | ||
if (magistrate.noError(result)) return result; | ||
} | ||
@@ -1293,4 +1276,3 @@ return magistrate.fail(i18n.t("core.validator.one_of.not_match_rule", { label })); | ||
isEmpty(value) { | ||
if (value === "" && this.config.allowEmpty) | ||
return false; | ||
if (value === "" && this.config.allowEmpty) return false; | ||
return super.isEmpty(value); | ||
@@ -1416,6 +1398,4 @@ } | ||
function toValidator(validator) { | ||
if (!validator) | ||
return; | ||
if (validator instanceof Validator) | ||
return validator; | ||
if (!validator) return; | ||
if (validator instanceof Validator) return validator; | ||
return new ObjectValidator(validator); | ||
@@ -1541,4 +1521,3 @@ } | ||
const trusted = await validator["validate"](source); | ||
if (magistrate.noError(trusted)) | ||
return trusted.ok; | ||
if (magistrate.noError(trusted)) return trusted.ok; | ||
const msg = await errorFormatter(trusted.errors); | ||
@@ -1545,0 +1524,0 @@ throw new ValidatorError(msg, trusted.errors); |
{ | ||
"name": "@aomex/core", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "aomex核心库", | ||
@@ -39,5 +39,5 @@ "type": "module", | ||
"openapi-types": "^12.1.3", | ||
"@aomex/internal-tools": "^1.0.1" | ||
"@aomex/internal-tools": "^1.0.2" | ||
}, | ||
"scripts": {} | ||
} |
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
203426
2554
Updated@aomex/internal-tools@^1.0.2