Skip to content

Commit

Permalink
fix: fixed some of the error handling and test
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Jul 25, 2024
1 parent e65c080 commit 061b8be
Show file tree
Hide file tree
Showing 4 changed files with 592 additions and 20 deletions.
10 changes: 5 additions & 5 deletions frontend/src/components/forms/TextInputComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const revalidateBus = useEventBus<void>("revalidate-bus");
* @param errorMessage - the error message
*/
const setError = (errorMessage: string | undefined) => {
error.value = errorMessage ?? "";
error.value = errorMessage || "";
/*
The error should be emitted whenever it is found, instead of watching and emitting only when it
Expand Down Expand Up @@ -94,17 +94,17 @@ watch([selectedValue], () => {
});
//We call all the validations
const validateInput = (newValue: string) => {
const validateInput = (newValue: string) => {
if (props.validations) {
setError(
props.validations
.map((validation) => validation(newValue))
.map((validation) => validation(newValue))
.filter((errorMessage) => {
if (errorMessage) return true;
return false;
})
})
.reduce(
(acc, errorMessage) => acc ?? errorMessage,
(acc, errorMessage) => acc || errorMessage,
props.errorMessage,
)
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/grouping/AddressGroupComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useFetchTo } from "@/composables/useFetch";
import type { CodeNameType, BusinessSearchResult } from "@/dto/CommonTypesDto";
import type { Address } from "@/dto/ApplyClientNumberDto";
// Validators
import { getValidations } from "@/helpers/validators/GlobalValidators";
import { getValidations } from "@/helpers/validators/BCeIDFormValidations";
import { submissionValidation } from "@/helpers/validators/SubmissionValidators";
// @ts-ignore
import Delete16 from "@carbon/icons-vue/es/trash-can/16";
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/helpers/validators/BCeIDFormValidations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ export const addValidation = (
if (!formFieldValidations[key]) formFieldValidations[key] = [];
formFieldValidations[key].push(validation);
};

export const getValidations = (key: string): ((value: any) => string)[] =>
key ? formFieldValidations[key] || [] : [];
Loading

0 comments on commit 061b8be

Please sign in to comment.