@nocobase/database 2.1.0-alpha.21 → 2.1.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -42,6 +42,19 @@ __export(field_validation_exports, {
|
|
|
42
42
|
module.exports = __toCommonJS(field_validation_exports);
|
|
43
43
|
var import_joi = __toESM(require("joi"));
|
|
44
44
|
var import_lodash = __toESM(require("lodash"));
|
|
45
|
+
function getFractionLength(value) {
|
|
46
|
+
const normalized = value.trim().replace(/,/g, "");
|
|
47
|
+
if (!normalized || /e/i.test(normalized)) {
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
const unsignedValue = normalized.startsWith("+") || normalized.startsWith("-") ? normalized.slice(1) : normalized;
|
|
51
|
+
const dotIndex = unsignedValue.indexOf(".");
|
|
52
|
+
if (dotIndex < 0) {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
return unsignedValue.slice(dotIndex + 1).length;
|
|
56
|
+
}
|
|
57
|
+
__name(getFractionLength, "getFractionLength");
|
|
45
58
|
function buildJoiSchema(validation, options) {
|
|
46
59
|
const { type, rules } = validation;
|
|
47
60
|
const { label, value } = options;
|
|
@@ -60,7 +73,21 @@ function buildJoiSchema(validation, options) {
|
|
|
60
73
|
rules.forEach((rule) => {
|
|
61
74
|
const args = import_lodash.default.cloneDeep(rule.args);
|
|
62
75
|
if (rule.name === "precision") {
|
|
63
|
-
|
|
76
|
+
const limit = Number(args == null ? void 0 : args.limit);
|
|
77
|
+
schema = schema.custom((currentValue, helpers) => {
|
|
78
|
+
if (Number.isNaN(limit)) {
|
|
79
|
+
return currentValue;
|
|
80
|
+
}
|
|
81
|
+
const originalValue = helpers.original;
|
|
82
|
+
if (originalValue === null || originalValue === void 0 || originalValue === "") {
|
|
83
|
+
return currentValue;
|
|
84
|
+
}
|
|
85
|
+
if (getFractionLength(String(originalValue)) > limit) {
|
|
86
|
+
return helpers.error("number.precision", { limit });
|
|
87
|
+
}
|
|
88
|
+
return currentValue;
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
64
91
|
}
|
|
65
92
|
if (!import_lodash.default.isEmpty(args)) {
|
|
66
93
|
if (rule.name === "pattern" && !import_lodash.default.isRegExp(args.regex)) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.23",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/logger": "2.1.0-alpha.
|
|
10
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
9
|
+
"@nocobase/logger": "2.1.0-alpha.23",
|
|
10
|
+
"@nocobase/utils": "2.1.0-alpha.23",
|
|
11
11
|
"async-mutex": "^0.3.2",
|
|
12
12
|
"chalk": "^4.1.1",
|
|
13
13
|
"cron-parser": "4.4.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
39
39
|
"directory": "packages/database"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "baa19dafe25e85b680b2fea7451f202831930c1c"
|
|
42
42
|
}
|