Skip to content

Commit

Permalink
fix: require salary and expenses to be 0 - 99999
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast authored Sep 28, 2023
1 parent 26449ae commit f76916f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
EMPLOYEE_MAX_WORKING_HOURS,
EMPLOYEE_MIN_WORKING_HOURS,
MAX_MONTHLY_PAY,
MAX_SHORT_STRING_LENGTH,
} from 'benefit/applicant/constants';
import {
Expand Down Expand Up @@ -106,19 +107,40 @@ export const getValidationSchema = (
}))
.required(t(VALIDATION_MESSAGE_KEYS.REQUIRED)),
[EMPLOYEE_KEYS.VACATION_MONEY]: Yup.number()
.min(0, (param) => ({
min: param.min,
key: VALIDATION_MESSAGE_KEYS.NUMBER_MIN,
}))
.max(MAX_MONTHLY_PAY, (param) => ({
max: param.max,
key: VALIDATION_MESSAGE_KEYS.NUMBER_MAX,
}))
.transform((_value, originalValue) => getNumberValue(originalValue))
.typeError(t(VALIDATION_MESSAGE_KEYS.NUMBER_INVALID))
.nullable()
.required(t(VALIDATION_MESSAGE_KEYS.REQUIRED)),
[EMPLOYEE_KEYS.MONTHLY_PAY]: Yup.number()
.min(0, (param) => ({
min: param.min,
key: VALIDATION_MESSAGE_KEYS.NUMBER_MIN,
}))
.max(MAX_MONTHLY_PAY, (param) => ({
max: param.max,
key: VALIDATION_MESSAGE_KEYS.NUMBER_MAX,
}))
.transform((_value, originalValue) => getNumberValue(originalValue))
.typeError(t(VALIDATION_MESSAGE_KEYS.NUMBER_INVALID))
.nullable()
.required(t(VALIDATION_MESSAGE_KEYS.REQUIRED)),
[EMPLOYEE_KEYS.OTHER_EXPENSES]: Yup.number()
.min(0, (param) => ({
min: param.min,
key: VALIDATION_MESSAGE_KEYS.NUMBER_MIN,
}))
.max(MAX_MONTHLY_PAY, (param) => ({
max: param.max,
key: VALIDATION_MESSAGE_KEYS.NUMBER_MAX,
}))
.transform((_value, originalValue) => getNumberValue(originalValue))
.typeError(t(VALIDATION_MESSAGE_KEYS.NUMBER_INVALID))
.nullable()
.required(t(VALIDATION_MESSAGE_KEYS.REQUIRED)),
}),
});
1 change: 1 addition & 0 deletions frontend/benefit/applicant/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum ROUTES {
}

export const MAX_DEMINIMIS_AID_TOTAL_AMOUNT = 200_000;
export const MAX_MONTHLY_PAY = 99_999;

export enum SUPPORTED_LANGUAGES {
FI = 'fi',
Expand Down

0 comments on commit f76916f

Please sign in to comment.