@aemforms/af-core 0.22.150 → 0.22.152
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/esm/afb-runtime.js +36 -11
- package/esm/types/src/data/DataValue.d.ts +1 -0
- package/esm/types/src/types/Json.d.ts +3 -0
- package/lib/BaseNode.js +7 -3
- package/lib/Field.js +2 -2
- package/lib/data/DataValue.d.ts +1 -0
- package/lib/data/DataValue.js +16 -0
- package/lib/rules/FunctionRuntime.js +6 -4
- package/lib/types/Json.d.ts +3 -0
- package/lib/types/Json.js +13 -4
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -26,7 +26,8 @@ const ConstraintType = Object.freeze({
|
|
|
26
26
|
MAX_ITEMS_MISMATCH: 'maxItemsMismatch',
|
|
27
27
|
EXPRESSION_MISMATCH: 'expressionMismatch',
|
|
28
28
|
EXCLUSIVE_MAXIMUM_MISMATCH: 'exclusiveMaximumMismatch',
|
|
29
|
-
EXCLUSIVE_MINIMUM_MISMATCH: 'exclusiveMinimumMismatch'
|
|
29
|
+
EXCLUSIVE_MINIMUM_MISMATCH: 'exclusiveMinimumMismatch',
|
|
30
|
+
ENUM_MISMATCH: 'enumMismatch'
|
|
30
31
|
});
|
|
31
32
|
const constraintKeys = Object.freeze({
|
|
32
33
|
pattern: ConstraintType.PATTERN_MISMATCH,
|
|
@@ -45,7 +46,8 @@ const constraintKeys = Object.freeze({
|
|
|
45
46
|
maxItems: ConstraintType.MAX_ITEMS_MISMATCH,
|
|
46
47
|
validationExpression: ConstraintType.EXPRESSION_MISMATCH,
|
|
47
48
|
exclusiveMinimum: ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH,
|
|
48
|
-
exclusiveMaximum: ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH
|
|
49
|
+
exclusiveMaximum: ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH,
|
|
50
|
+
enum: ConstraintType.ENUM_MISMATCH
|
|
49
51
|
});
|
|
50
52
|
const defaultConstraintTypeMessages = Object.freeze({
|
|
51
53
|
[ConstraintType.PATTERN_MISMATCH]: 'Please match the format requested.',
|
|
@@ -64,7 +66,8 @@ const defaultConstraintTypeMessages = Object.freeze({
|
|
|
64
66
|
[ConstraintType.MAX_ITEMS_MISMATCH]: 'Specify a number of items equal to or less than ${0}.',
|
|
65
67
|
[ConstraintType.EXPRESSION_MISMATCH]: 'Please enter a valid value.',
|
|
66
68
|
[ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH]: 'Value must be greater than ${0}.',
|
|
67
|
-
[ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH]: 'Value must be less than ${0}.'
|
|
69
|
+
[ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH]: 'Value must be less than ${0}.',
|
|
70
|
+
[ConstraintType.ENUM_MISMATCH]: 'Please select a value from the allowed options.'
|
|
68
71
|
});
|
|
69
72
|
let customConstraintTypeMessages = {};
|
|
70
73
|
const getConstraintTypeMessages = () => {
|
|
@@ -358,6 +361,22 @@ class DataValue {
|
|
|
358
361
|
$bindToField(field) {
|
|
359
362
|
if (this.$_fields.indexOf(field) === -1) {
|
|
360
363
|
this.$_fields.push(field);
|
|
364
|
+
this._checkForTypeConflicts(field);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
_checkForTypeConflicts(newField) {
|
|
368
|
+
if (this.$_fields.length <= 1) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const newFieldType = newField.type;
|
|
372
|
+
const conflictingFields = this.$_fields.filter(existingField => existingField &&
|
|
373
|
+
existingField !== newField &&
|
|
374
|
+
existingField.type !== newFieldType);
|
|
375
|
+
if (conflictingFields.length > 0) {
|
|
376
|
+
const conflictDetails = conflictingFields.map(field => `Field "${field.id}" (${field.type})`).join(', ');
|
|
377
|
+
console.error('Type conflict detected: Multiple fields with same dataRef have different types. ' +
|
|
378
|
+
`New field '${newField.id}' (${newFieldType}) conflicts with: ${conflictDetails}. ` +
|
|
379
|
+
`DataRef: ${this.$name}`);
|
|
361
380
|
}
|
|
362
381
|
}
|
|
363
382
|
$convertToDataValue() {
|
|
@@ -1393,6 +1412,9 @@ const addOnly = (includeOrExclude) => (...fieldTypes) => (target, propertyKey, d
|
|
|
1393
1412
|
const set = descriptor.set;
|
|
1394
1413
|
if (set != undefined) {
|
|
1395
1414
|
descriptor.set = function (value) {
|
|
1415
|
+
if (this === this._ruleNode) {
|
|
1416
|
+
console.error(`Property '${propertyKey}' is being set through a proxy, which is not supported. Please use globals.functions.setProperty instead.`);
|
|
1417
|
+
}
|
|
1396
1418
|
if (fieldTypes.indexOf(this.fieldType) > -1 === includeOrExclude) {
|
|
1397
1419
|
set.call(this, value);
|
|
1398
1420
|
}
|
|
@@ -1649,16 +1671,16 @@ class BaseNode {
|
|
|
1649
1671
|
this.form.getEventQueue().runPendingQueue();
|
|
1650
1672
|
}
|
|
1651
1673
|
withDependencyTrackingControl(disableDependencyTracking, callback) {
|
|
1652
|
-
const currentDependencyTracking = this.form
|
|
1674
|
+
const currentDependencyTracking = this.form?.ruleEngine.getDependencyTracking();
|
|
1653
1675
|
if (disableDependencyTracking) {
|
|
1654
|
-
this.form
|
|
1676
|
+
this.form?.ruleEngine.setDependencyTracking(false);
|
|
1655
1677
|
}
|
|
1656
1678
|
try {
|
|
1657
1679
|
return callback();
|
|
1658
1680
|
}
|
|
1659
1681
|
finally {
|
|
1660
1682
|
if (disableDependencyTracking) {
|
|
1661
|
-
this.form
|
|
1683
|
+
this.form?.ruleEngine.setDependencyTracking(currentDependencyTracking);
|
|
1662
1684
|
}
|
|
1663
1685
|
}
|
|
1664
1686
|
}
|
|
@@ -2851,7 +2873,7 @@ const request = async (context, uri, httpVerb, payload, success, error, headers)
|
|
|
2851
2873
|
method: httpVerb
|
|
2852
2874
|
};
|
|
2853
2875
|
let inputPayload;
|
|
2854
|
-
let encryptOutput = {};
|
|
2876
|
+
let encryptOutput = {}, cryptoMetadata = null;
|
|
2855
2877
|
try {
|
|
2856
2878
|
if (payload instanceof Promise) {
|
|
2857
2879
|
payload = await payload;
|
|
@@ -2865,6 +2887,7 @@ const request = async (context, uri, httpVerb, payload, success, error, headers)
|
|
|
2865
2887
|
encryptOutput = { ...payload };
|
|
2866
2888
|
headers = { ...payload.headers };
|
|
2867
2889
|
payload = payload.body;
|
|
2890
|
+
cryptoMetadata = payload.cryptoMetadata;
|
|
2868
2891
|
inputPayload = payload;
|
|
2869
2892
|
}
|
|
2870
2893
|
if (payload && payload instanceof FileObject && payload.data instanceof File) {
|
|
@@ -2929,6 +2952,7 @@ const request = async (context, uri, httpVerb, payload, success, error, headers)
|
|
|
2929
2952
|
response.originalRequest = {
|
|
2930
2953
|
url: endpoint,
|
|
2931
2954
|
method: httpVerb,
|
|
2955
|
+
...(cryptoMetadata && { cryptoMetadata }),
|
|
2932
2956
|
...encryptOutput
|
|
2933
2957
|
};
|
|
2934
2958
|
response.submitter = targetField;
|
|
@@ -3427,10 +3451,11 @@ class FunctionRuntimeImpl {
|
|
|
3427
3451
|
throw error;
|
|
3428
3452
|
}
|
|
3429
3453
|
let finalHeaders = {};
|
|
3430
|
-
let finalBody = {};
|
|
3454
|
+
let finalBody = {}, finalCryptoMetadata = null;
|
|
3431
3455
|
if (args.length === 5) {
|
|
3432
3456
|
finalBody = payload.body || {};
|
|
3433
3457
|
finalHeaders = payload.headers || {};
|
|
3458
|
+
finalCryptoMetadata = payload.cryptoMetadata;
|
|
3434
3459
|
}
|
|
3435
3460
|
else {
|
|
3436
3461
|
finalBody = payload || {};
|
|
@@ -3450,7 +3475,7 @@ class FunctionRuntimeImpl {
|
|
|
3450
3475
|
};
|
|
3451
3476
|
}
|
|
3452
3477
|
}
|
|
3453
|
-
const finalPayload = { 'body': finalBody, 'headers': finalHeaders };
|
|
3478
|
+
const finalPayload = { 'body': finalBody, 'headers': finalHeaders, ...(finalCryptoMetadata && { cryptoMetadata: finalCryptoMetadata }) };
|
|
3454
3479
|
try {
|
|
3455
3480
|
const response = await request(interpreter.globals, uri, httpVerb, finalPayload, success, errorFn, finalHeaders);
|
|
3456
3481
|
return response;
|
|
@@ -4782,10 +4807,10 @@ class Field extends Scriptable {
|
|
|
4782
4807
|
if (this._jsonModel.enforceEnum === true && value != null) {
|
|
4783
4808
|
const fn = constraints.enum;
|
|
4784
4809
|
if (value instanceof Array && this.isArrayType()) {
|
|
4785
|
-
return value.every(x => fn(this.enum || [], x).valid);
|
|
4810
|
+
return value.every(x => fn(this._jsonModel.enum || [], x).valid);
|
|
4786
4811
|
}
|
|
4787
4812
|
else {
|
|
4788
|
-
return fn(this.enum || [], value).valid;
|
|
4813
|
+
return fn(this._jsonModel.enum || [], value).valid;
|
|
4789
4814
|
}
|
|
4790
4815
|
}
|
|
4791
4816
|
return true;
|
|
@@ -13,6 +13,7 @@ export default class DataValue {
|
|
|
13
13
|
setValue(typedValue: any, originalValue: any, fromField: FieldModel): void;
|
|
14
14
|
get $type(): string;
|
|
15
15
|
$bindToField(field: FieldModel): void;
|
|
16
|
+
private _checkForTypeConflicts;
|
|
16
17
|
$convertToDataValue(): DataValue;
|
|
17
18
|
get $isDataGroup(): boolean;
|
|
18
19
|
$addDataNode(name: string | number, value: DataValue, override?: boolean): void;
|
|
@@ -148,6 +148,7 @@ export declare const ConstraintType: Readonly<{
|
|
|
148
148
|
EXPRESSION_MISMATCH: "expressionMismatch";
|
|
149
149
|
EXCLUSIVE_MAXIMUM_MISMATCH: "exclusiveMaximumMismatch";
|
|
150
150
|
EXCLUSIVE_MINIMUM_MISMATCH: "exclusiveMinimumMismatch";
|
|
151
|
+
ENUM_MISMATCH: "enumMismatch";
|
|
151
152
|
}>;
|
|
152
153
|
export declare const constraintKeys: Readonly<{
|
|
153
154
|
pattern: "patternMismatch";
|
|
@@ -167,6 +168,7 @@ export declare const constraintKeys: Readonly<{
|
|
|
167
168
|
validationExpression: "expressionMismatch";
|
|
168
169
|
exclusiveMinimum: "exclusiveMinimumMismatch";
|
|
169
170
|
exclusiveMaximum: "exclusiveMaximumMismatch";
|
|
171
|
+
enum: "enumMismatch";
|
|
170
172
|
}>;
|
|
171
173
|
export declare const setCustomDefaultConstraintTypeMessages: (messages: Record<string, string>) => void;
|
|
172
174
|
export declare const getConstraintTypeMessages: () => {
|
|
@@ -187,5 +189,6 @@ export declare const getConstraintTypeMessages: () => {
|
|
|
187
189
|
expressionMismatch: "Please enter a valid value.";
|
|
188
190
|
exclusiveMinimumMismatch: "Value must be greater than ${0}.";
|
|
189
191
|
exclusiveMaximumMismatch: "Value must be less than ${0}.";
|
|
192
|
+
enumMismatch: "Please select a value from the allowed options.";
|
|
190
193
|
};
|
|
191
194
|
export {};
|
package/lib/BaseNode.js
CHANGED
|
@@ -107,6 +107,9 @@ const addOnly = (includeOrExclude) => (...fieldTypes) => (target, propertyKey, d
|
|
|
107
107
|
const set = descriptor.set;
|
|
108
108
|
if (set != undefined) {
|
|
109
109
|
descriptor.set = function (value) {
|
|
110
|
+
if (this === this._ruleNode) {
|
|
111
|
+
console.error(`Property '${propertyKey}' is being set through a proxy, which is not supported. Please use globals.functions.setProperty instead.`);
|
|
112
|
+
}
|
|
110
113
|
if (fieldTypes.indexOf(this.fieldType) > -1 === includeOrExclude) {
|
|
111
114
|
set.call(this, value);
|
|
112
115
|
}
|
|
@@ -347,16 +350,17 @@ class BaseNode {
|
|
|
347
350
|
this.form.getEventQueue().runPendingQueue();
|
|
348
351
|
}
|
|
349
352
|
withDependencyTrackingControl(disableDependencyTracking, callback) {
|
|
350
|
-
|
|
353
|
+
var _a, _b, _c;
|
|
354
|
+
const currentDependencyTracking = (_a = this.form) === null || _a === void 0 ? void 0 : _a.ruleEngine.getDependencyTracking();
|
|
351
355
|
if (disableDependencyTracking) {
|
|
352
|
-
this.form.ruleEngine.setDependencyTracking(false);
|
|
356
|
+
(_b = this.form) === null || _b === void 0 ? void 0 : _b.ruleEngine.setDependencyTracking(false);
|
|
353
357
|
}
|
|
354
358
|
try {
|
|
355
359
|
return callback();
|
|
356
360
|
}
|
|
357
361
|
finally {
|
|
358
362
|
if (disableDependencyTracking) {
|
|
359
|
-
this.form.ruleEngine.setDependencyTracking(currentDependencyTracking);
|
|
363
|
+
(_c = this.form) === null || _c === void 0 ? void 0 : _c.ruleEngine.setDependencyTracking(currentDependencyTracking);
|
|
360
364
|
}
|
|
361
365
|
}
|
|
362
366
|
}
|
package/lib/Field.js
CHANGED
|
@@ -504,10 +504,10 @@ class Field extends Scriptable_1.default {
|
|
|
504
504
|
if (this._jsonModel.enforceEnum === true && value != null) {
|
|
505
505
|
const fn = constraints.enum;
|
|
506
506
|
if (value instanceof Array && this.isArrayType()) {
|
|
507
|
-
return value.every(x => fn(this.enum || [], x).valid);
|
|
507
|
+
return value.every(x => fn(this._jsonModel.enum || [], x).valid);
|
|
508
508
|
}
|
|
509
509
|
else {
|
|
510
|
-
return fn(this.enum || [], value).valid;
|
|
510
|
+
return fn(this._jsonModel.enum || [], value).valid;
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
return true;
|
package/lib/data/DataValue.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export default class DataValue {
|
|
|
13
13
|
setValue(typedValue: any, originalValue: any, fromField: FieldModel): void;
|
|
14
14
|
get $type(): string;
|
|
15
15
|
$bindToField(field: FieldModel): void;
|
|
16
|
+
private _checkForTypeConflicts;
|
|
16
17
|
$convertToDataValue(): DataValue;
|
|
17
18
|
get $isDataGroup(): boolean;
|
|
18
19
|
$addDataNode(name: string | number, value: DataValue, override?: boolean): void;
|
package/lib/data/DataValue.js
CHANGED
|
@@ -53,6 +53,22 @@ class DataValue {
|
|
|
53
53
|
$bindToField(field) {
|
|
54
54
|
if (this.$_fields.indexOf(field) === -1) {
|
|
55
55
|
this.$_fields.push(field);
|
|
56
|
+
this._checkForTypeConflicts(field);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
_checkForTypeConflicts(newField) {
|
|
60
|
+
if (this.$_fields.length <= 1) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const newFieldType = newField.type;
|
|
64
|
+
const conflictingFields = this.$_fields.filter(existingField => existingField &&
|
|
65
|
+
existingField !== newField &&
|
|
66
|
+
existingField.type !== newFieldType);
|
|
67
|
+
if (conflictingFields.length > 0) {
|
|
68
|
+
const conflictDetails = conflictingFields.map(field => `Field "${field.id}" (${field.type})`).join(', ');
|
|
69
|
+
console.error('Type conflict detected: Multiple fields with same dataRef have different types. ' +
|
|
70
|
+
`New field '${newField.id}' (${newFieldType}) conflicts with: ${conflictDetails}. ` +
|
|
71
|
+
`DataRef: ${this.$name}`);
|
|
56
72
|
}
|
|
57
73
|
}
|
|
58
74
|
$convertToDataValue() {
|
|
@@ -37,7 +37,7 @@ const request = (context, uri, httpVerb, payload, success, error, headers) => __
|
|
|
37
37
|
method: httpVerb
|
|
38
38
|
};
|
|
39
39
|
let inputPayload;
|
|
40
|
-
let encryptOutput = {};
|
|
40
|
+
let encryptOutput = {}, cryptoMetadata = null;
|
|
41
41
|
try {
|
|
42
42
|
if (payload instanceof Promise) {
|
|
43
43
|
payload = yield payload;
|
|
@@ -51,6 +51,7 @@ const request = (context, uri, httpVerb, payload, success, error, headers) => __
|
|
|
51
51
|
encryptOutput = Object.assign({}, payload);
|
|
52
52
|
headers = Object.assign({}, payload.headers);
|
|
53
53
|
payload = payload.body;
|
|
54
|
+
cryptoMetadata = payload.cryptoMetadata;
|
|
54
55
|
inputPayload = payload;
|
|
55
56
|
}
|
|
56
57
|
if (payload && payload instanceof FileObject_1.FileObject && payload.data instanceof File) {
|
|
@@ -109,7 +110,7 @@ const request = (context, uri, httpVerb, payload, success, error, headers) => __
|
|
|
109
110
|
};
|
|
110
111
|
try {
|
|
111
112
|
const response = yield (0, Fetch_1.request)(endpoint, inputPayload, requestOptions);
|
|
112
|
-
response.originalRequest = Object.assign({ url: endpoint, method: httpVerb }, encryptOutput);
|
|
113
|
+
response.originalRequest = Object.assign(Object.assign({ url: endpoint, method: httpVerb }, (cryptoMetadata && { cryptoMetadata })), encryptOutput);
|
|
113
114
|
response.submitter = targetField;
|
|
114
115
|
const enhancedPayload = Object.assign(Object.assign({}, baseEnhancedPayload), { response, request: response.originalRequest });
|
|
115
116
|
if ((response === null || response === void 0 ? void 0 : response.status) >= 200 && (response === null || response === void 0 ? void 0 : response.status) <= 299) {
|
|
@@ -602,10 +603,11 @@ class FunctionRuntimeImpl {
|
|
|
602
603
|
throw error;
|
|
603
604
|
}
|
|
604
605
|
let finalHeaders = {};
|
|
605
|
-
let finalBody = {};
|
|
606
|
+
let finalBody = {}, finalCryptoMetadata = null;
|
|
606
607
|
if (args.length === 5) {
|
|
607
608
|
finalBody = payload.body || {};
|
|
608
609
|
finalHeaders = payload.headers || {};
|
|
610
|
+
finalCryptoMetadata = payload.cryptoMetadata;
|
|
609
611
|
}
|
|
610
612
|
else {
|
|
611
613
|
finalBody = payload || {};
|
|
@@ -619,7 +621,7 @@ class FunctionRuntimeImpl {
|
|
|
619
621
|
finalHeaders = Object.assign(Object.assign({}, finalHeaders), retryOptions.headers);
|
|
620
622
|
}
|
|
621
623
|
}
|
|
622
|
-
const finalPayload = { 'body': finalBody, 'headers': finalHeaders };
|
|
624
|
+
const finalPayload = Object.assign({ 'body': finalBody, 'headers': finalHeaders }, (finalCryptoMetadata && { cryptoMetadata: finalCryptoMetadata }));
|
|
623
625
|
try {
|
|
624
626
|
const response = yield (0, exports.request)(interpreter.globals, uri, httpVerb, finalPayload, success, errorFn, finalHeaders);
|
|
625
627
|
return response;
|
package/lib/types/Json.d.ts
CHANGED
|
@@ -148,6 +148,7 @@ export declare const ConstraintType: Readonly<{
|
|
|
148
148
|
EXPRESSION_MISMATCH: "expressionMismatch";
|
|
149
149
|
EXCLUSIVE_MAXIMUM_MISMATCH: "exclusiveMaximumMismatch";
|
|
150
150
|
EXCLUSIVE_MINIMUM_MISMATCH: "exclusiveMinimumMismatch";
|
|
151
|
+
ENUM_MISMATCH: "enumMismatch";
|
|
151
152
|
}>;
|
|
152
153
|
export declare const constraintKeys: Readonly<{
|
|
153
154
|
pattern: "patternMismatch";
|
|
@@ -167,6 +168,7 @@ export declare const constraintKeys: Readonly<{
|
|
|
167
168
|
validationExpression: "expressionMismatch";
|
|
168
169
|
exclusiveMinimum: "exclusiveMinimumMismatch";
|
|
169
170
|
exclusiveMaximum: "exclusiveMaximumMismatch";
|
|
171
|
+
enum: "enumMismatch";
|
|
170
172
|
}>;
|
|
171
173
|
export declare const setCustomDefaultConstraintTypeMessages: (messages: Record<string, string>) => void;
|
|
172
174
|
export declare const getConstraintTypeMessages: () => {
|
|
@@ -187,5 +189,6 @@ export declare const getConstraintTypeMessages: () => {
|
|
|
187
189
|
expressionMismatch: "Please enter a valid value.";
|
|
188
190
|
exclusiveMinimumMismatch: "Value must be greater than ${0}.";
|
|
189
191
|
exclusiveMaximumMismatch: "Value must be less than ${0}.";
|
|
192
|
+
enumMismatch: "Please select a value from the allowed options.";
|
|
190
193
|
};
|
|
191
194
|
export {};
|
package/lib/types/Json.js
CHANGED
|
@@ -25,7 +25,8 @@ exports.ConstraintType = Object.freeze({
|
|
|
25
25
|
MAX_ITEMS_MISMATCH: 'maxItemsMismatch',
|
|
26
26
|
EXPRESSION_MISMATCH: 'expressionMismatch',
|
|
27
27
|
EXCLUSIVE_MAXIMUM_MISMATCH: 'exclusiveMaximumMismatch',
|
|
28
|
-
EXCLUSIVE_MINIMUM_MISMATCH: 'exclusiveMinimumMismatch'
|
|
28
|
+
EXCLUSIVE_MINIMUM_MISMATCH: 'exclusiveMinimumMismatch',
|
|
29
|
+
ENUM_MISMATCH: 'enumMismatch'
|
|
29
30
|
});
|
|
30
31
|
exports.constraintKeys = Object.freeze({
|
|
31
32
|
pattern: exports.ConstraintType.PATTERN_MISMATCH,
|
|
@@ -44,7 +45,8 @@ exports.constraintKeys = Object.freeze({
|
|
|
44
45
|
maxItems: exports.ConstraintType.MAX_ITEMS_MISMATCH,
|
|
45
46
|
validationExpression: exports.ConstraintType.EXPRESSION_MISMATCH,
|
|
46
47
|
exclusiveMinimum: exports.ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH,
|
|
47
|
-
exclusiveMaximum: exports.ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH
|
|
48
|
+
exclusiveMaximum: exports.ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH,
|
|
49
|
+
enum: exports.ConstraintType.ENUM_MISMATCH
|
|
48
50
|
});
|
|
49
51
|
const defaultConstraintTypeMessages = Object.freeze({
|
|
50
52
|
[exports.ConstraintType.PATTERN_MISMATCH]: 'Please match the format requested.',
|
|
@@ -63,7 +65,8 @@ const defaultConstraintTypeMessages = Object.freeze({
|
|
|
63
65
|
[exports.ConstraintType.MAX_ITEMS_MISMATCH]: 'Specify a number of items equal to or less than ${0}.',
|
|
64
66
|
[exports.ConstraintType.EXPRESSION_MISMATCH]: 'Please enter a valid value.',
|
|
65
67
|
[exports.ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH]: 'Value must be greater than ${0}.',
|
|
66
|
-
[exports.ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH]: 'Value must be less than ${0}.'
|
|
68
|
+
[exports.ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH]: 'Value must be less than ${0}.',
|
|
69
|
+
[exports.ConstraintType.ENUM_MISMATCH]: 'Please select a value from the allowed options.'
|
|
67
70
|
});
|
|
68
71
|
const transformObjectKeys = (obj, transformer) => {
|
|
69
72
|
if (typeof obj !== 'object' || obj === null) {
|
|
@@ -81,7 +84,13 @@ const transformObjectKeys = (obj, transformer) => {
|
|
|
81
84
|
};
|
|
82
85
|
let customConstraintTypeMessages = {};
|
|
83
86
|
const setCustomDefaultConstraintTypeMessages = (messages) => {
|
|
84
|
-
|
|
87
|
+
const validMessages = Object.entries(messages).reduce((acc, [key, value]) => {
|
|
88
|
+
if (exports.constraintKeys[key] !== undefined) {
|
|
89
|
+
acc[key] = value;
|
|
90
|
+
}
|
|
91
|
+
return acc;
|
|
92
|
+
}, {});
|
|
93
|
+
customConstraintTypeMessages = transformObjectKeys(validMessages, (key) => {
|
|
85
94
|
return exports.constraintKeys[key];
|
|
86
95
|
});
|
|
87
96
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.152",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@adobe/json-formula": "0.1.50",
|
|
40
|
-
"@aemforms/af-formatters": "^0.22.
|
|
40
|
+
"@aemforms/af-formatters": "^0.22.152"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|