nox-validation 1.2.7 → 1.2.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.
- package/lib/validate.js +13 -1
- package/package.json +1 -1
package/lib/validate.js
CHANGED
|
@@ -543,10 +543,22 @@ const generateErrorMessage = (
|
|
|
543
543
|
|
|
544
544
|
const handleRule = (rule, field, value, addError, currentPath, formData, error_messages) => {
|
|
545
545
|
const ruleValue = rule?.value;
|
|
546
|
-
|
|
546
|
+
let messageValue = Array.isArray(ruleValue) ? ruleValue.join(", ") : String(ruleValue);
|
|
547
547
|
const fieldLabel = formatLabel(field.display_label);
|
|
548
548
|
const custom_message = rule?.custom_message;
|
|
549
549
|
|
|
550
|
+
if (rule.case === constants.rulesTypes.ONE_OF && choices.includes(field?.meta?.interface)) {
|
|
551
|
+
const fieldChoices = field?.meta?.options?.choices || [];
|
|
552
|
+
const ruleValues = Array.isArray(ruleValue) ? ruleValue : [ruleValue];
|
|
553
|
+
|
|
554
|
+
const labelValuePairs = ruleValues.map((val) => {
|
|
555
|
+
const matched = fieldChoices.find((item) => String(item.value) === String(val));
|
|
556
|
+
return matched ? `${matched.label} (${matched.value})` : val;
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
messageValue = labelValuePairs.join(", ");
|
|
560
|
+
}
|
|
561
|
+
|
|
550
562
|
const addValidationError = (ruleKey, extraValues = {}, custom_message) =>
|
|
551
563
|
addError(
|
|
552
564
|
currentPath,
|