Skip to content

Commit

Permalink
[PLAT-14951] Add positive interger error message to pitr param step
Browse files Browse the repository at this point in the history
Summary:
**Context**
Though we error when the user tries to submit values less than 1, we should also error when the user
submits decimal numbers. This is because we can only send retention time in seconds to the backend.
Furthermore, the backend stores retention time in a long. This means we shouldn't provide decimals in
the request.

**Change**
This diff adds validation for positive integer input before running the minimum value validation for PITR retention
period.

Test Plan:
Test using decimals, negative integers, negative values with decimals, positive integers, positive integers
lower than the expected minimum and positive integers which exceed the minimum.
{F276016}
{F276017}
{F276018}
{F276019}
{F276020}
{F276026}
{F276027}

Reviewers: rmadhavan

Reviewed By: rmadhavan

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D37343
  • Loading branch information
Jethro-M committed Aug 16, 2024
1 parent 6d4d8f6 commit 15fd362
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,20 @@ export const ConfigurePitrStep = ({ isFormDisabled }: ConfigureAlertStepProps) =
inputProps={{ min: pitrRetentionPeriodMinValue }}
rules={{
required: t('error.pitrRetentionPeriodValueRequired'),
min: {
value: pitrRetentionPeriodMinValue,
message: t('error.pitrRetentionPeriodValueMinimum')
validate: {
pattern: (value) => {
const integerPattern = /^\d+$/;
return (
integerPattern.test(value?.toString() ?? '') ||
t('error.pitrRetentionPeriodValueIntegerValidation')
);
},
min: (value) => {
return (
(value as number) >= pitrRetentionPeriodMinValue ||
t('error.pitrRetentionPeriodValueMinimum')
);
}
}
}}
disabled={isFormDisabled}
Expand Down
5 changes: 3 additions & 2 deletions managed/ui/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,9 @@
"tooltip": "A longer snapshot retention period requires more disk space."
},
"error": {
"pitrRetentionPeriodValueRequired": "Required.",
"pitrRetentionPeriodValueRequired": "Please enter a positive integer.",
"pitrRetentionPeriodValueMinimum": "Minimum 5 minutes.",
"pitrRetentionPeriodValueIntegerValidation": "Please enter a positive integer.",
"pitrRetentionPeriodUnitRequired": "Required."
}
},
Expand Down Expand Up @@ -2372,4 +2373,4 @@
"yugabyteInc": "Yugabyte, Inc."
}
}
}
}

0 comments on commit 15fd362

Please sign in to comment.