diff --git a/frontend/src/modules/Traces/LatencyModalForm.tsx b/frontend/src/modules/Traces/LatencyModalForm.tsx index 91a00b12e3..b98b9ee2fb 100644 --- a/frontend/src/modules/Traces/LatencyModalForm.tsx +++ b/frontend/src/modules/Traces/LatencyModalForm.tsx @@ -1,6 +1,6 @@ import React from "react"; import { Modal, Form, InputNumber, Col, Row } from "antd"; -import { Store } from "antd/lib/form/interface"; +import { NamePath, Store } from "antd/lib/form/interface"; interface LatencyModalFormProps { onCreate: (values: Store) => void; //Store is defined in antd forms library @@ -13,13 +13,32 @@ const LatencyModalForm: React.FC = ({ onCancel, latencyFilterValues, }) => { - const [form] = Form.useForm(); + const [form] = Form.useForm(); + + const validateMinValue = ({ getFieldValue }: {getFieldValue: (name: NamePath) => any}) => ({ + validator(_, value: any) { + if (value < getFieldValue('max')) { + return Promise.resolve(); + } + return Promise.reject(new Error('Min value should be less than Max value')); + }, + }) + + const validateMaxValue = ({ getFieldValue }: {getFieldValue: (name: NamePath) => any}) => ({ + validator(_, value: any) { + if (value > getFieldValue('min')) { + return Promise.resolve(); + } + return Promise.reject(new Error('Max value should be greater than Min value')); + }, + }) + return ( { form @@ -31,7 +50,7 @@ const LatencyModalForm: React.FC = ({ .catch((info) => { console.log("Validate Failed:", info); }); - }} + }} >
= ({ - +