Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add integer validation to card limit #51011

Merged
merged 10 commits into from
Oct 28, 2024
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ const translations = {
error: {
invalidCategoryLength: 'The category name exceeds 255 characters. Please shorten it or choose a different category.',
invalidAmount: 'Please enter a valid amount before continuing.',
invalidIntegerAmount: 'Please enter a whole dollar amount before continuing.',
invalidTaxAmount: ({amount}: RequestAmountParams) => `Maximum tax amount is ${amount}`,
invalidSplit: 'The sum of splits must equal the total amount.',
invalidSplitParticipants: 'Please enter an amount greater than zero for at least two participants.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ const translations = {
error: {
invalidCategoryLength: 'La longitud de la categoría escogida excede el máximo permitido (255). Por favor, escoge otra categoría o acorta la categoría primero.',
invalidAmount: 'Por favor, ingresa un importe válido antes de continuar.',
invalidIntegerAmount: 'Por favor, introduce una cantidad en dólares completos antes de continuar.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use https://chatgpt.com/g/g-2dgOQl5VM-english-to-spanish-translator to get the translation and then ask for confirmation on our Slack channel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did translate from chatGPT, can you ask on slack? my invite is still pending due to some issue with expensify and slack, i requested to join but they are still to add me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got Por favor introduce una cantidad entera en dólares antes de continuar. with JamesGPT. I asked for confirmation here: https://expensify.slack.com/archives/C01GTK53T8Q/p1729289783370669

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@twilight2294 , can you please fill out this form? Once we have invites for Slack we'll invite you https://docs.google.com/forms/d/e/1FAIpQLSeZ1JyVRYUrHugT8SyIL6b7dFYUgR3TEa1jigccREqD2hfLxQ/viewform

Thx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rayane-djouah any updates ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped the Slack thread

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct translation is:

Por favor, introduce una cantidad entera en dólares antes de continuar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, can you please complete the checklist

invalidTaxAmount: ({amount}: RequestAmountParams) => `El importe máximo del impuesto es ${amount}`,
invalidSplit: 'La suma de las partes debe ser igual al importe total.',
invalidSplitParticipants: 'Introduce un importe superior a cero para al menos dos participantes.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ function WorkspaceEditCardLimitPage({route}: WorkspaceEditCardLimitPageProps) {
const errors = ValidationUtils.getFieldRequiredErrors(values, [INPUT_IDS.LIMIT]);

// We only want integers to be sent as the limit
if (!Number.isInteger(Number(values.limit))) {
if (!Number(values.limit)) {
errors.limit = translate('iou.error.invalidAmount');
} else if (!Number.isInteger(Number(values.limit))) {
errors.limit = translate('iou.error.invalidIntegerAmount');
}

return errors;
Expand Down
5 changes: 4 additions & 1 deletion src/pages/workspace/expensifyCard/issueNew/LimitStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ function LimitStep() {
const errors = ValidationUtils.getFieldRequiredErrors(values, [INPUT_IDS.LIMIT]);

// We only want integers to be sent as the limit
if (!Number(values.limit) || !Number.isInteger(Number(values.limit))) {
if (!Number(values.limit)) {
errors.limit = translate('iou.error.invalidAmount');
} else if (!Number.isInteger(Number(values.limit))) {
errors.limit = translate('iou.error.invalidIntegerAmount');
}

return errors;
},
[translate],
Expand Down
Loading