Skip to content

Commit

Permalink
chore(3314): enforce distinct PO and TL idir
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinedu Olebu committed Nov 12, 2024
1 parent fa173cd commit 8302d07
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions app/validation-schemas/private-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,24 @@ const _privateCloudEditRequestBodySchema = _privateCloudCreateRequestBodySchema.
}),
);

export const privateCloudEditRequestBodySchema = _privateCloudEditRequestBodySchema.refine(isEmailUnique, {
message: 'Project Owner and Primary Technical Lead must not have the same email.',
});
export const privateCloudEditRequestBodySchema = _privateCloudEditRequestBodySchema
.merge(
z.object({
isAgMinistryChecked: z.boolean().optional(),
}),
)
.refine(
(formData) => {
return AGMinistries.includes(formData.ministry) ? formData.isAgMinistryChecked : true;
},
{
message: 'AG Ministry Checkbox should be checked.',
path: ['isAgMinistryChecked'],
},
)
.refine(isEmailUnique, {
message: 'Project Owner and Primary Technical Lead must not have the same email.',
});

export const privateCloudRequestDecisionBodySchema = _privateCloudEditRequestBodySchema.merge(
z.object({
Expand Down
22 changes: 19 additions & 3 deletions app/validation-schemas/public-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,25 @@ const _publicCloudEditRequestBodySchema = _publicCloudCreateRequestBodySchema.me
}),
);

export const publicCloudEditRequestBodySchema = _publicCloudEditRequestBodySchema.refine(isEmailUnique, {
message: 'Project Owner and Primary Technical Lead must not have the same email.',
});
export const publicCloudEditRequestBodySchema = _publicCloudEditRequestBodySchema
.merge(
z.object({
isAgMinistryChecked: z.boolean().optional(),
isEaApproval: z.boolean().optional(),
}),
)
.refine(
(formData) => {
return AGMinistries.includes(formData.ministry) ? formData.isAgMinistryChecked : true;
},
{
message: 'AG Ministry Checkbox should be checked.',
path: ['isAgMinistryChecked'],
},
)
.refine(isEmailUnique, {
message: 'Project Owner and Primary Technical Lead must not have the same email.',
});

export const publicCloudRequestDecisionBodySchema = _publicCloudEditRequestBodySchema.merge(
z.object({
Expand Down

0 comments on commit 8302d07

Please sign in to comment.