Skip to content

Commit

Permalink
Add validation message for date of birth input field in user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
DonOmalVindula committed Aug 26, 2024
1 parent 868308c commit decd6b2
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions features/admin.users.v1/components/user-profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1391,20 +1391,48 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
fluid
/>
);
} else if (schema?.name === "dateOfBirth") {
return (
<Field
data-testid={ `${ testId }-profile-form-${ schema.name }-input` }
name={ schema.name }
label={ fieldName }
required={ schema.required }
requiredErrorMessage={ fieldName + " is required" }
placeholder="YYYY-MM-DD"
type="text"
value={ profileInfo.get(schema.name) }
key={ key }
readOnly={ isReadOnly || schema.mutability === ProfileConstants.READONLY_SCHEMA }
validation={ (value: string, validation: Validation) => {
if (!RegExp(schema.regEx).test(value)) {
validation.isValid = false;
validation.errorMessages
.push(t("users:forms.validation.dateFormatError", {
field: fieldName
}));
}
} }
maxLength={ schema.maxLength
? schema.maxLength
: ProfileConstants.CLAIM_VALUE_MAX_LENGTH
}
/>
);
} else {
return (
<Field
data-testid={ `${ testId }-profile-form-${ schema.name }-input` }
name={ schema.name }
label={ schema.name === "profileUrl" ? "Profile Image URL" :
( (!commonConfig.userEditSection.showEmail && schema.name === "userName")
? fieldName +" (Email)"
? fieldName + " (Email)"
: fieldName
)
}
required={ schema.required }
requiredErrorMessage={ fieldName + " " + "is required" }
placeholder={ "Enter your" + " " + fieldName }
requiredErrorMessage={ fieldName + " is required" }
placeholder={ "Enter your " + fieldName }
type="text"
value={ profileInfo.get(schema.name) }
key={ key }
Expand Down

0 comments on commit decd6b2

Please sign in to comment.