Skip to content

Commit

Permalink
Merge pull request #32394 from Expensify/aldo_add-long-category-valid…
Browse files Browse the repository at this point in the history
…ation

Add validation error for category
  • Loading branch information
marcochavezf authored Dec 11, 2023
2 parents 6476a45 + 1243b91 commit fad9f53
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const CONST = {
ALLOWED_RECEIPT_EXTENSIONS: ['jpg', 'jpeg', 'gif', 'png', 'pdf', 'htm', 'html', 'text', 'rtf', 'doc', 'tif', 'tiff', 'msword', 'zip', 'xml', 'message'],
},

// This is limit set on servers, do not update without wider internal discussion
API_TRANSACTION_CATEGORY_MAX_LENGTH: 255,

AUTO_AUTH_STATE: {
NOT_STARTED: 'not-started',
SIGNING_IN: 'signing-in',
Expand Down
6 changes: 5 additions & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,10 @@ function MoneyRequestConfirmationList(props) {
if (_.isEmpty(selectedParticipants)) {
return;
}

if (props.iouCategory && props.iouCategory.length > CONST.API_TRANSACTION_CATEGORY_MAX_LENGTH) {
setFormError('iou.error.invalidCategoryLength');
return;
}
if (props.iouType === CONST.IOU.TYPE.SEND) {
if (!paymentMethod) {
return;
Expand Down Expand Up @@ -483,6 +486,7 @@ function MoneyRequestConfirmationList(props) {
props.isEditingSplitBill,
props.iouType,
props.isDistanceRequest,
props.iouCategory,
isDistanceRequestWithoutRoute,
props.iouCurrencyCode,
props.iouAmount,
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ export default {
tagSelection: ({tagName}: TagSelectionParams) => `Select a ${tagName} to add additional organization to your money.`,
categorySelection: 'Select a category to add additional organization to your money.',
error: {
invalidCategoryLength: 'The length of the category chosen exceeds the maximum allowed (255). Please choose a different or shorten the category name first.',
invalidAmount: 'Please enter a valid amount before continuing.',
invalidSplit: 'Split amounts do not equal total amount',
other: 'Unexpected error, please try again later',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ export default {
tagSelection: ({tagName}: TagSelectionParams) => `Seleccione una ${tagName} para organizar mejor tu dinero.`,
categorySelection: 'Seleccione una categoría para organizar mejor tu dinero.',
error: {
invalidCategoryLength: 'El largo 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 monto válido antes de continuar.',
invalidSplit: 'La suma de las partes no equivale al monto total',
other: 'Error inesperado, por favor inténtalo más tarde',
Expand Down

0 comments on commit fad9f53

Please sign in to comment.