Repository: provectus/kafka-ui
Issue: Disable 0 and negative values in Topic Creation
Labels: type/enhancement
scope/frontend
status/accepted
status/confirmed

### Is your proposal related to a problem?

<!--
  Provide a clear and concise description of what the problem is.
  For example, "I'm always frustrated when..."
-->

When creating a new topic, you can select 0, -1, etc. values in Replication Factor and Min In Sync Replicas, though these values are not allowed by default -- pop-um messages instruct the user about that.

### Describe the solution you'd like

<!--
  Provide a clear and concise description of what you want to happen.
-->

Disable the selection of 0 and other negative values in Replication Factor and Min In Sync Replicas.

### Describe alternatives you've considered

<!--
  Let us know about other solutions you've tried or researched.
-->

(Write your answer here.)

### Additional context

<!--
  Is there anything else you can add about the proposal?
  You might want to link to related issues here, if you haven't already.
-->

(Write your answer here.)


Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/kafka-ui-react-app/src/components/Topics/New/New.tsx b/kafka-ui-react-app/src/components/Topics/New/New.tsx
index 5fb9fbac743..de4075912c2 100644
--- a/kafka-ui-react-app/src/components/Topics/New/New.tsx
+++ b/kafka-ui-react-app/src/components/Topics/New/New.tsx
@@ -21,6 +21,7 @@ interface RouterParams {
 
 const New: React.FC = () => {
   const methods = useForm<TopicFormData>({
+    mode: 'onTouched',
     resolver: yupResolver(topicFormValidationSchema),
   });
   const { clusterName } = useParams<RouterParams>();
diff --git a/kafka-ui-react-app/src/components/Topics/shared/Form/TopicForm.tsx b/kafka-ui-react-app/src/components/Topics/shared/Form/TopicForm.tsx
index 52f96e9c67f..a81f213a246 100644
--- a/kafka-ui-react-app/src/components/Topics/shared/Form/TopicForm.tsx
+++ b/kafka-ui-react-app/src/components/Topics/shared/Form/TopicForm.tsx
@@ -70,6 +70,7 @@ const TopicForm: React.FC<Props> = ({
                 <Input
                   type="number"
                   placeholder="Number of partitions"
+                  min="1"
                   defaultValue="1"
                   name="partitions"
                   inputSize="M"
@@ -89,6 +90,7 @@ const TopicForm: React.FC<Props> = ({
               <Input
                 type="number"
                 placeholder="Replication Factor"
+                min="1"
                 defaultValue="1"
                 name="replicationFactor"
                 inputSize="M"
@@ -104,6 +106,7 @@ const TopicForm: React.FC<Props> = ({
             <Input
               type="number"
               placeholder="Min In Sync Replicas"
+              min="1"
               defaultValue="1"
               name="minInsyncReplicas"
               inputSize="M"
@@ -149,6 +152,7 @@ const TopicForm: React.FC<Props> = ({
           <InputLabel>Maximum message size in bytes *</InputLabel>
           <Input
             type="number"
+            min="1"
             defaultValue="1000012"
             name="maxMessageBytes"
             inputSize="M"
diff --git a/kafka-ui-react-app/src/lib/yupExtended.ts b/kafka-ui-react-app/src/lib/yupExtended.ts
index 77382b6bef0..fab2a290018 100644
--- a/kafka-ui-react-app/src/lib/yupExtended.ts
+++ b/kafka-ui-react-app/src/lib/yupExtended.ts
@@ -50,13 +50,13 @@ export const topicFormValidationSchema = yup.object().shape({
       TOPIC_NAME_VALIDATION_PATTERN,
       'Only alphanumeric, _, -, and . allowed'
     ),
-  partitions: yup.number().required(),
-  replicationFactor: yup.number().required(),
-  minInsyncReplicas: yup.number().required(),
+  partitions: yup.number().min(1).required(),
+  replicationFactor: yup.number().min(1).required(),
+  minInsyncReplicas: yup.number().min(1).required(),
   cleanupPolicy: yup.string().required(),
   retentionMs: yup.number().min(-1, 'Must be greater than or equal to -1'),
   retentionBytes: yup.number(),
-  maxMessageBytes: yup.number().required(),
+  maxMessageBytes: yup.number().min(1).required(),
   customParams: yup.array().of(
     yup.object().shape({
       name: yup.string().required(),


Test patch: