@stemy/ngx-dynamic-form 19.9.7 → 19.9.8
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.
|
@@ -319,10 +319,10 @@ function withName(fn, name) {
|
|
|
319
319
|
mainFn.validatorName = name;
|
|
320
320
|
return mainFn;
|
|
321
321
|
}
|
|
322
|
-
function validateEach(
|
|
322
|
+
function validateEach(cb, name) {
|
|
323
323
|
return withName((control, field) => {
|
|
324
324
|
const value = control.value;
|
|
325
|
-
return
|
|
325
|
+
return field.type === "array" ? Array.isArray(value) && value.every(v => cb(v, field)) : cb(value, field);
|
|
326
326
|
}, name);
|
|
327
327
|
}
|
|
328
328
|
function addFieldValidators(field, validators) {
|
|
@@ -414,14 +414,14 @@ function arrayLengthValidation(min = 1, max = Number.MAX_SAFE_INTEGER) {
|
|
|
414
414
|
return !Array.isArray(value) || (min <= value.length && value.length <= max);
|
|
415
415
|
}, "arrayLength");
|
|
416
416
|
}
|
|
417
|
-
function minLengthValidation(minLength
|
|
418
|
-
return validateEach(
|
|
417
|
+
function minLengthValidation(minLength) {
|
|
418
|
+
return validateEach(v => typeof v == "string" && v.length >= minLength, "minLength");
|
|
419
419
|
}
|
|
420
|
-
function maxLengthValidation(maxLength
|
|
421
|
-
return validateEach(
|
|
420
|
+
function maxLengthValidation(maxLength) {
|
|
421
|
+
return validateEach(v => typeof v == "string" && v.length <= maxLength, "maxLength");
|
|
422
422
|
}
|
|
423
|
-
function minValueValidation(
|
|
424
|
-
return validateEach(
|
|
423
|
+
function minValueValidation() {
|
|
424
|
+
return validateEach((v, f) => {
|
|
425
425
|
const type = f.props.type || "number";
|
|
426
426
|
const min = type.includes("date")
|
|
427
427
|
? convertToDate(f.props.min, type) : Number(f.props.min ?? 0);
|
|
@@ -432,8 +432,8 @@ function minValueValidation(each) {
|
|
|
432
432
|
return v == null || v >= min;
|
|
433
433
|
}, "minValue");
|
|
434
434
|
}
|
|
435
|
-
function maxValueValidation(
|
|
436
|
-
return validateEach(
|
|
435
|
+
function maxValueValidation() {
|
|
436
|
+
return validateEach((v, f) => {
|
|
437
437
|
const type = f.props.type || "number";
|
|
438
438
|
const max = type.includes("date")
|
|
439
439
|
? convertToDate(f.props.max, type) : Number(f.props.max ?? 0);
|
|
@@ -448,7 +448,7 @@ function setFieldMinDate(field, min) {
|
|
|
448
448
|
setFieldDefault(field, min);
|
|
449
449
|
setFieldProp(field, "min", min);
|
|
450
450
|
setFieldValue(field, min);
|
|
451
|
-
addFieldValidators(field, [minValueValidation(
|
|
451
|
+
addFieldValidators(field, [minValueValidation()]);
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
class ModelUtils {
|
|
@@ -1248,8 +1248,8 @@ class DynamicFormSchemaService {
|
|
|
1248
1248
|
autocomplete: property.autocomplete,
|
|
1249
1249
|
pattern: property.pattern,
|
|
1250
1250
|
step: isNaN(sub.step) ? property.step : sub.step,
|
|
1251
|
-
min: sub.minimum,
|
|
1252
|
-
max: sub.maximum,
|
|
1251
|
+
min: sub.minimum ?? sub.min,
|
|
1252
|
+
max: sub.maximum ?? sub.max,
|
|
1253
1253
|
minLength: sub.minLength,
|
|
1254
1254
|
maxLength: sub.maxLength,
|
|
1255
1255
|
placeholder: property.placeholder,
|
|
@@ -1293,8 +1293,8 @@ class DynamicFormSchemaService {
|
|
|
1293
1293
|
return this.builder.createFormInput(property.id, {
|
|
1294
1294
|
...this.getFormFieldData(property, options),
|
|
1295
1295
|
type,
|
|
1296
|
-
min: convertToDateFormat(property.min, property.format),
|
|
1297
|
-
max: convertToDateFormat(property.max, property.format),
|
|
1296
|
+
min: convertToDateFormat(property.minimum ?? property.min, property.format),
|
|
1297
|
+
max: convertToDateFormat(property.maximum ?? property.max, property.format),
|
|
1298
1298
|
}, parent, options);
|
|
1299
1299
|
}
|
|
1300
1300
|
getFormSelectConfig($enum, property, options, parent) {
|
|
@@ -1432,10 +1432,10 @@ class DynamicFormSchemaService {
|
|
|
1432
1432
|
validators.maxLength = maxLengthValidation(property.maxLength);
|
|
1433
1433
|
}
|
|
1434
1434
|
if (!isNaN(property.minimum)) {
|
|
1435
|
-
validators.min = minValueValidation(
|
|
1435
|
+
validators.min = minValueValidation();
|
|
1436
1436
|
}
|
|
1437
1437
|
if (!isNaN(property.maximum)) {
|
|
1438
|
-
validators.max = maxValueValidation(
|
|
1438
|
+
validators.max = maxValueValidation();
|
|
1439
1439
|
}
|
|
1440
1440
|
// if (isString(property.pattern) && property.pattern.length) {
|
|
1441
1441
|
// validators.pattern = property.pattern;
|
|
@@ -1450,16 +1450,16 @@ class DynamicFormSchemaService {
|
|
|
1450
1450
|
if (!items)
|
|
1451
1451
|
return;
|
|
1452
1452
|
if (!isNaN(items.minLength)) {
|
|
1453
|
-
validators.itemsMinLength = minLengthValidation(items.minLength
|
|
1453
|
+
validators.itemsMinLength = minLengthValidation(items.minLength);
|
|
1454
1454
|
}
|
|
1455
1455
|
if (!isNaN(items.maxLength)) {
|
|
1456
|
-
validators.itemsMaxLength = maxLengthValidation(items.maxLength
|
|
1456
|
+
validators.itemsMaxLength = maxLengthValidation(items.maxLength);
|
|
1457
1457
|
}
|
|
1458
1458
|
if (!isNaN(items.minimum)) {
|
|
1459
|
-
validators.itemsMinValue = minValueValidation(
|
|
1459
|
+
validators.itemsMinValue = minValueValidation();
|
|
1460
1460
|
}
|
|
1461
1461
|
if (!isNaN(items.maximum)) {
|
|
1462
|
-
validators.itemsMaxValue = maxValueValidation(
|
|
1462
|
+
validators.itemsMaxValue = maxValueValidation();
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
1465
1465
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: DynamicFormSchemaService, deps: [{ token: i2.OpenApiService }, { token: i0.Injector }, { token: DynamicFormBuilderService }], target: i0.ɵɵFactoryTarget.Injectable });
|