Skip to content

Commit

Permalink
refactor(compensations): type failsafe for location duplicate check
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiazom committed Sep 5, 2024
1 parent e976647 commit 81deeef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions studio/schemas/objects/compensations/bonusesByLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ export const bonusesByLocation = defineField({
],
validation: (Rule) =>
Rule.custom((bonusesByLocation) => {
const isNotDuplicate: boolean = checkForDuplicateLocations(
bonusesByLocation as DocumentWithLocation[] | undefined,
);
return (
checkForDuplicateLocations(
bonusesByLocation as DocumentWithLocation[] | undefined,
) ||
isNotDuplicate ||
"Each location should be listed only once in the bonuses list. You can assign the same bonus amount to multiple locations, but make sure no location appears more than once."
);
}),
Expand Down
7 changes: 4 additions & 3 deletions studio/schemas/objects/compensations/salariesByLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ export const salariesByLocation = defineField({
],
validation: (Rule) =>
Rule.custom((salariesByLocation) => {
const isNotDuplicate: boolean = checkForDuplicateLocations(
salariesByLocation as DocumentWithLocation[] | undefined,
);
return (
checkForDuplicateLocations(
salariesByLocation as DocumentWithLocation[] | undefined,
) ||
isNotDuplicate ||
"Each location should be listed only once in the salaries list. You can assign the same salary data to multiple locations, but make sure no location appears more than once."
);
}),
Expand Down

0 comments on commit 81deeef

Please sign in to comment.