Skip to content

Commit 30ec412

Browse files
authored
🐛 Enhance error message for archetype create/edit tag fields (#1653)
Add a custom error message for the min array length check of the criteria tags and archetype tags fields on the create/edit archetype form. The new error message properly handles a minimum count of 1 or >1. Resolves: https://issues.redhat.com/browse/MTA-1945 The error message now: ![Screenshot from 2024-01-03 17-42-41](https://github.com/konveyor/tackle2-ui/assets/3985964/4805dc06-836c-4371-991a-9fce97e9fb09) Signed-off-by: Scott J Dickerson <[email protected]>
1 parent cc40cb8 commit 30ec412

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

client/public/locales/en/translation.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@
391391
"repositoryType": "Repository type",
392392
"review": "Review",
393393
"reviewedArchetype": "Archetype reviewed",
394-
395394
"reviews": "Reviews",
396395
"reviewComments": "Review comments",
397396
"risk": "Risk",
@@ -422,6 +421,7 @@
422421
"suggestedAdoptionPlan": "Suggested adoption plan",
423422
"svnConfig": "Subversion configuration",
424423
"tableView": "Table view",
424+
"tag": "Tag",
425425
"tag(s)": "Tag(s)",
426426
"tagCount": "Tag count",
427427
"tagDeleted": "Tag deleted",
@@ -446,7 +446,6 @@
446446
"user": "User",
447447
"version": "Version",
448448
"workPriority": "Work priority",
449-
"tag": "Tag",
450449
"YAMLTemplate": "YAML template"
451450
},
452451
"titles": {
@@ -479,6 +478,8 @@
479478
"max": "This field must be less than {{value}}.",
480479
"maxLength": "This field must contain fewer than {{length}} characters.",
481480
"min": "This field must be greater than {{value}}.",
481+
"minCount": "At least one {{type}} must be selected.",
482+
"minCount_plural": "At least {{count}} {{types}} must be selected.",
482483
"minLength": "This field must contain at least {{length}} characters.",
483484
"minOneStakeholderOrGroupRequired": "At least one stakeholder or stakeholder groups is required.",
484485
"required": "This field is required."

client/src/app/pages/archetypes/components/archetype-form/archetype-form.tsx

+14-2
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,25 @@ const ArchetypeForm: React.FC<ArchetypeFormProps> = ({
136136
criteria: yup
137137
.array()
138138
.of(yup.object({ id: yup.number(), name: yup.string() }))
139-
.min(1)
139+
.min(1, ({ min }) =>
140+
t("validation.minCount", {
141+
count: min,
142+
type: t("terms.tag").toLocaleLowerCase(),
143+
types: t("terms.tags").toLocaleLowerCase(),
144+
})
145+
)
140146
.required(t("validation.required")),
141147

142148
tags: yup
143149
.array()
144150
.of(yup.object({ id: yup.number(), name: yup.string() }))
145-
.min(1)
151+
.min(1, ({ min }) =>
152+
t("validation.minCount", {
153+
count: min,
154+
type: t("terms.tag").toLocaleLowerCase(),
155+
types: t("terms.tags").toLocaleLowerCase(),
156+
})
157+
)
146158
.required(t("validation.required")),
147159

148160
stakeholders: yup

0 commit comments

Comments
 (0)