@flowgram.ai/form 0.2.31 → 0.2.32
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.
- package/dist/esm/index.js +19 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +19 -9
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/esm/index.js
CHANGED
|
@@ -1364,14 +1364,15 @@ var FormModel = class {
|
|
|
1364
1364
|
this.setValueIn(name, void 0);
|
|
1365
1365
|
}
|
|
1366
1366
|
async validateIn(name) {
|
|
1367
|
-
|
|
1367
|
+
const validateOptions = this.getValidateOptions();
|
|
1368
|
+
if (!validateOptions) {
|
|
1368
1369
|
return;
|
|
1369
1370
|
}
|
|
1370
|
-
const validateKeys = Object.keys(
|
|
1371
|
+
const validateKeys = Object.keys(validateOptions).filter(
|
|
1371
1372
|
(pattern) => Glob.isMatch(pattern, name)
|
|
1372
1373
|
);
|
|
1373
1374
|
const validatePromises = validateKeys.map(async (validateKey) => {
|
|
1374
|
-
const validate =
|
|
1375
|
+
const validate = validateOptions[validateKey];
|
|
1375
1376
|
return validate({
|
|
1376
1377
|
value: this.getValueIn(name),
|
|
1377
1378
|
formValues: this.values,
|
|
@@ -1381,18 +1382,27 @@ var FormModel = class {
|
|
|
1381
1382
|
});
|
|
1382
1383
|
return Promise.all(validatePromises);
|
|
1383
1384
|
}
|
|
1385
|
+
getValidateOptions() {
|
|
1386
|
+
const validate = this._options.validate;
|
|
1387
|
+
if (typeof validate === "function") {
|
|
1388
|
+
return validate(this.values, this.context);
|
|
1389
|
+
}
|
|
1390
|
+
return validate;
|
|
1391
|
+
}
|
|
1384
1392
|
async validate() {
|
|
1385
|
-
|
|
1393
|
+
const validateOptions = this.getValidateOptions();
|
|
1394
|
+
if (!validateOptions) {
|
|
1386
1395
|
return [];
|
|
1387
1396
|
}
|
|
1388
|
-
const feedbacksArrPromises = Object.keys(
|
|
1389
|
-
const validate =
|
|
1390
|
-
const
|
|
1397
|
+
const feedbacksArrPromises = Object.keys(validateOptions).map(async (nameRule) => {
|
|
1398
|
+
const validate = validateOptions[nameRule];
|
|
1399
|
+
const values = this.values;
|
|
1400
|
+
const paths = Glob.findMatchPathsWithEmptyValue(values, nameRule);
|
|
1391
1401
|
return Promise.all(
|
|
1392
1402
|
paths.map(async (path) => {
|
|
1393
1403
|
const result = await validate({
|
|
1394
|
-
value: get4(
|
|
1395
|
-
formValues:
|
|
1404
|
+
value: get4(values, path),
|
|
1405
|
+
formValues: values,
|
|
1396
1406
|
context: this.context,
|
|
1397
1407
|
name: path
|
|
1398
1408
|
});
|