Skip to content

Commit

Permalink
Merge pull request #26745 from paultsimura/fix-26344
Browse files Browse the repository at this point in the history
fix: Web - No Error Generated When Adding a Track Distance Rate of 0.00
  • Loading branch information
marcochavezf authored Sep 11, 2023
2 parents 6488e9f + c1388d8 commit 38c3e94
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,7 @@ export default {
fastReimbursementsVBACopy: "You're all set to reimburse receipts from your bank account!",
updateCustomUnitError: "Your changes couldn't be saved. The workspace was modified while you were offline, please try again.",
invalidRateError: 'Please enter a valid rate',
lowRateError: 'Rate must be greater than 0',
},
bills: {
manageYourBills: 'Manage your bills',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,7 @@ export default {
fastReimbursementsVBACopy: '¡Todo listo para reembolsar recibos desde tu cuenta bancaria!',
updateCustomUnitError: 'Los cambios no han podido ser guardados. El espacio de trabajo ha sido modificado mientras estabas desconectado. Por favor, inténtalo de nuevo.',
invalidRateError: 'Por favor, introduce una tarifa válida',
lowRateError: 'La tarifa debe ser mayor que 0',
},
bills: {
manageYourBills: 'Gestiona tus facturas',
Expand Down
4 changes: 3 additions & 1 deletion src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ class WorkspaceRateAndUnitPage extends React.Component {
validate(values) {
const errors = {};
const decimalSeparator = this.props.toLocaleDigit('.');
const rateValueRegex = RegExp(String.raw`^\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');
const rateValueRegex = RegExp(String.raw`^-?\d{0,8}([${getPermittedDecimalSeparator(decimalSeparator)}]\d{1,3})?$`, 'i');
if (!rateValueRegex.test(values.rate) || values.rate === '') {
errors.rate = 'workspace.reimburse.invalidRateError';
} else if (parseFloat(values.rate) <= 0) {
errors.rate = 'workspace.reimburse.lowRateError';
}
return errors;
}
Expand Down

0 comments on commit 38c3e94

Please sign in to comment.