Skip to content

Commit

Permalink
fix(global): 🐛 fix add registration info not working
Browse files Browse the repository at this point in the history
fix add registration info not working

Ref: #56
  • Loading branch information
PritamIT2023 committed Jun 25, 2024
1 parent f03f0e4 commit 2ce47de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
19 changes: 17 additions & 2 deletions app/formValidationMap.registry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getFormikRequiredMessage } from "@wrappid/core";
import moment from "moment";
import { string, date, mixed, boolean, object } from "yup";
import { string, date, mixed, boolean } from "yup";

export const ValidationsRegistry = {
profileBaic: {
Expand Down Expand Up @@ -158,6 +158,21 @@ export const ValidationsRegistry = {
/^[a-zA-Z0-9\s-/]+$/,
"Special charecters are not allowed except - and /"
),
registrationDocument: object().nullable(),
registrationDocument: mixed()
.test("fileSize", "File size must be less than 5MB", (value) => {
if (!value) return true;
return value.size <= 5242880;
})
.test(
"fileType",
"Only PDF and Doc files allowed",
(value) => {
if (!value) return true; // Skip validation if no file selected

const supportedTypes = ["application/pdf", "application/msword"];

return supportedTypes.includes(value.type);
}
)
}
};
6 changes: 3 additions & 3 deletions service/functions/profile.function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ const putRegistrationDetailsFunc = async (req: any, res: any) => {
const personId: any = req.params.id;

if (
req.file["registrationDocument"] &&
req.file["registrationDocument"][0]
req.files["registrationDocument"] &&
req.files["registrationDocument"][0]
) {
//eslint-disable-next-line no-undef
file_url = "file_url";
file_url = req.files["registrationDocument"][0].location;
// await getUrl(
// req.file["registrationDocument"][0].filename
// ? req.file["registrationDocument"][0].filename
Expand Down

0 comments on commit 2ce47de

Please sign in to comment.