Skip to content

Commit

Permalink
Update positive amount error message on Admin panel forms
Browse files Browse the repository at this point in the history
  • Loading branch information
ani-kalpachka committed Jul 21, 2024
1 parent 20de1ce commit 1317d6e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/admin/campaigns/grid/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const validationSchema: yup.SchemaOf<CampaignAdminCreateFormData> = yup
title: yup.string().trim().min(10).max(200).required(),
slug: yup.string().trim().min(10).max(200).optional(),
description: yup.string().trim().min(50).max(60000).required(),
targetAmount: yup.number().integer().positive().required(),
targetAmount: yup.number().integer().positive('validation:positive-amount').required(),
allowDonationOnComplete: yup.bool().optional(),
campaignTypeId: yup.string().uuid().required(),
beneficiaryId: yup.string().uuid().required(),
Expand Down
2 changes: 1 addition & 1 deletion src/components/admin/campaigns/grid/EditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const validationSchema: yup.SchemaOf<Omit<CampaignEditFormData, 'campaignFiles'>
title: yup.string().trim().min(10).max(200).required(),
slug: yup.string().trim().min(10).max(200).required(),
description: yup.string().trim().min(50).required(),
targetAmount: yup.number().integer().positive().required(),
targetAmount: yup.number().integer().positive('validation:positive-amount').required(),
allowDonationOnComplete: yup.bool().optional(),
campaignTypeId: yup.string().uuid().required(),
beneficiaryId: yup.string().required(),
Expand Down
4 changes: 2 additions & 2 deletions src/components/admin/expenses/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function Form() {
is: (value: string) => value !== undefined,
then: yup
.number()
.positive()
.positive('validation:positive-amount')
.required()
.test({
name: 'max',
Expand All @@ -66,7 +66,7 @@ export default function Form() {
return value < Number(currentAmount)
},
}),
otherwise: yup.number().positive().integer().required(),
otherwise: yup.number().positive('validation:positive-amount').integer().required(),
}),
vaultId: yup.string().trim().uuid().required(),
deleted: yup.boolean().required(),
Expand Down
2 changes: 1 addition & 1 deletion src/components/admin/recurring-donation/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const validationSchema = yup
personId: yup.string().trim().uuid().required(),
extSubscriptionId: yup.string().trim().required(),
extCustomerId: yup.string().trim().required(),
money: yup.number().min(0).positive().required(),
money: yup.number().min(0).positive('validation:positive-amount').required(),
currency: yup.string().oneOf(validCurrencies).required(),
sourceVault: yup.string().trim().uuid().required(),
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/admin/transfers/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function CreateForm({ campaigns }: Props) {
is: (value: string) => value !== undefined,
then: yup
.number()
.positive()
.positive('validation:positive-amount')
.required()
.test({
name: 'max',
Expand Down
4 changes: 2 additions & 2 deletions src/components/admin/withdrawals/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function CreateForm() {
is: (value: string) => value !== undefined,
then: yup
.number()
.positive()
.positive('validation:positive-amount')
.required()
.test({
name: 'max',
Expand All @@ -55,7 +55,7 @@ export default function CreateForm() {
return Number(value) < Number(fromMoney(currentAmount))
},
}),
otherwise: yup.number().positive().integer().required(),
otherwise: yup.number().positive('validation:positive-amount').integer().required(),
}),
reason: yup.string().trim().min(1).max(300).required(),
targetDate: yup.date().required(),
Expand Down
2 changes: 1 addition & 1 deletion src/components/admin/withdrawals/EditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const validationSchema: yup.SchemaOf<WithdrawalData> = yup
.defined()
.shape({
status: yup.string().trim().min(1).max(10).required(),
amount: yup.number().positive().required(),
amount: yup.number().positive('validation:positive-amount').required(),
reason: yup.string().trim().min(1).max(300).required(),
currency: yup.string().oneOf(Object.values(Currency)).required(),
sourceVaultId: yup.string().uuid().required(),
Expand Down

0 comments on commit 1317d6e

Please sign in to comment.