Skip to content

Commit

Permalink
Error message is incorrect displayed when entered less than expected …
Browse files Browse the repository at this point in the history
…characters in full name field.

Signed-off-by: Sreang Rathanak <[email protected]>
  • Loading branch information
Sreang Rathanak committed Jul 8, 2024
1 parent bdabc39 commit 8d5d3ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions signup-ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
"full_name_validation": "Please enter a valid name",
"full_name_all_spaces_validation": "Please enter a valid name.",
"full_name_in_lng_validation": "Full Name has to be in Khmer only.",
"full_name_min_validation": "Full Name has to be greater than or equal to {minLength} characters.",
"full_name_max_validation": "Full Name has to be less than or equal to {maxLength} characters.",
"password_validation": "Password does not meet the password policy. Click on \"i\" to know more.",
"password_validation_must_match": "New Password and Confirm New Password do not match.",
"register_password_validation_must_match": "Password and Confirm Password do not match.",
Expand Down
2 changes: 2 additions & 0 deletions signup-ui/public/locales/km.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
"full_name_validation": "សូមបញ្ចូលគោត្តនាម-នាមឱ្យបានត្រឹមត្រូវ",
"full_name_all_spaces_validation": "សូមបញ្ចូលឈ្មោះអ្នកឲ្យបានត្រឹមត្រូវ",
"full_name_in_lng_validation": "គោត្តនាម-នាមត្រូវតែមានតែអក្សរខ្មែរ",
"full_name_min_validation": "គោត្តនាម-នាមត្រូវតែតិចជាង ឬស្មើនឹង {minLength}តួអក្សរ",
"full_name_max_validation": "គោត្តនាម-នាមត្រូវតែច្រើនជាង ឬស្មើនឹង {maxLength}តួអក្សរ",
"password_validation": "ពាក្យ​សម្ងាត់​មិន​ត្រូវ​តាម​គោលការណ៍​លេខ​សម្ងាត់​ទេ។ ចុចលើ \"i\" ដើម្បីដឹងបន្ថែម។",
"password_validation_must_match": "ពាក្យសម្ងាត់ថ្មី និងបញ្ជាក់ពាក្យសម្ងាត់ថ្មីមិនត្រូវគ្នាទេ។",
"register_password_validation_must_match": "ពាក្យសម្ងាត់ និងបញ្ជាក់ពាក្យសម្ងាត់មិនត្រូវគ្នាទេ។",
Expand Down
14 changes: 13 additions & 1 deletion signup-ui/src/pages/shared/validation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TFunction } from "i18next";
import i18next from "i18next";
import * as yup from "yup";

import { SettingsDto } from "~typings/types";
Expand Down Expand Up @@ -26,6 +26,18 @@ export const validateFullName = (settings: SettingsDto) =>
.string()
.strict(true)
.trim("full_name_all_spaces_validation")
.min(
settings.response.configs["fullname.length.min"],
i18next.t("full_name_min_validation", {
minLength: settings.response.configs["fullname.length.min"],
})
)
.max(
settings.response.configs["fullname.length.max"],
i18next.t("full_name_max_validation", {
maxLength: settings.response.configs["fullname.length.max"],
})
)
.matches(new RegExp(settings.response.configs["fullname.pattern"]), {
message: "full_name_in_lng_validation",
excludeEmptyString: true,
Expand Down
2 changes: 2 additions & 0 deletions signup-ui/src/resources.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ interface Resources {
full_name_validation: string;
full_name_all_spaces_validation: string;
full_name_in_lng_validation: string;
full_name_min_validation: string;
full_name_max_validation: string;
password_validation: string;
password_validation_must_match: string;
register_password_validation_must_match: string;
Expand Down

0 comments on commit 8d5d3ec

Please sign in to comment.