From b0718ce3bc6eca87871bfb85298b6e0585690e9b Mon Sep 17 00:00:00 2001 From: Elena Stoeva Date: Tue, 22 Oct 2024 11:46:58 +0100 Subject: [PATCH] Add validation for integer --- .../edit_data_retention_modal.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal/edit_data_retention_modal.tsx b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal/edit_data_retention_modal.tsx index 12b7789f39051..f747abca19f05 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal/edit_data_retention_modal.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal/edit_data_retention_modal.tsx @@ -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