Skip to content

Commit

Permalink
Add validation for integer
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaStoeva committed Oct 22, 2024
1 parent 628daf4 commit b0718ce
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ const configurationFormSchema: FormSchema = {
),
formatters: [fieldFormatters.toInt],
validations: [
{
validator: ({ value }) => {
// TODO: Replace with validator added in https://github.com/elastic/kibana/pull/196527/
if (!Number.isInteger(Number(value ?? ''))) {
return {
message: i18n.translate(
'xpack.idxMgmt.dataStreamsDetailsPanel.editDataRetentionModal.dataRetentionFieldIntegerError',
{
defaultMessage: 'Only integers are allowed.',
}
),
};
}
},
},
{
validator: ({ value, formData, customData }) => {
// We only need to validate the data retention field if infiniteRetentionPeriod is set to false
Expand Down

0 comments on commit b0718ce

Please sign in to comment.