Skip to content

Commit

Permalink
Update studio/schemas/objects/compensations/pension.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Mathias Oterhals Myklebust <[email protected]>
  • Loading branch information
anemne and mathiazom authored Sep 5, 2024
1 parent dc0e3e8 commit 4cbd58e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions studio/schemas/objects/compensations/pension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ export const pension = defineField({
type: "number",
initialValue: 7,
description: `Specify the percentage of the pension provided by Variant for employees. The value should be a positive number and will be used to calculate the pension amount.`,
validation: (Rule) =>
validation: (Rule) => [
Rule.min(0)
.max(100)
.error("The pension percentage must be a number between 0 and 100."),
Rule.custom((value, context) => {
if (
context.document?.showSalaryCalculator &&
(value === undefined || value === null)
) {
return "Please enter a pension percentage. This is required when the salary calculator is enabled.";
}
if (value !== undefined && (value < 0 || value > 100)) {
return "The pension percentage must be a number between 0 and 100.";
}
return true;
}),
],
});

0 comments on commit 4cbd58e

Please sign in to comment.