Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEN-2181]: enhance samplers input-validation with isEmpty function (#…
…2161) This pull request introduces the `isEmpty` utility function and integrates it across various components to improve the handling of empty values. The most important changes include the addition of the `isEmpty` function, its use in form validation, and updates to the `ErrorSampler` and `ProbabilisticSampler` components to handle empty values more effectively. ### Introduction of `isEmpty` utility function: * [`frontend/webapp/utils/functions/resolvers/is-emtpy/index.ts`](diffhunk://#diff-134d27b73ff1fb66f7be69a1d2b2d0476adcc2ac12a120aaa2c92caa63402df1R1-R12): Added a new `isEmpty` function to strictly check for empty values, allowing values like `0` and `false`. * [`frontend/webapp/utils/functions/resolvers/index.ts`](diffhunk://#diff-24c64e1f6bad8c9ac4c2e338e9d6be1654e7da44da8447c1008d3aa080ef1f38R3): Exported the new `isEmpty` function. ### Integration of `isEmpty` in form components: * [`frontend/webapp/containers/main/actions/action-form-body/custom-fields/error-sampler.tsx`](diffhunk://#diff-4b3cc5e7cbd14f55ad2bd0df1acb6014426f8fc8afb94e38d3e45f7ee51e5491L1-R3): Updated to use `isEmpty` for checking empty values and added `useEffect` to handle initial empty state. [[1]](diffhunk://#diff-4b3cc5e7cbd14f55ad2bd0df1acb6014426f8fc8afb94e38d3e45f7ee51e5491L1-R3) [[2]](diffhunk://#diff-4b3cc5e7cbd14f55ad2bd0df1acb6014426f8fc8afb94e38d3e45f7ee51e5491L27-R35) * [`frontend/webapp/containers/main/actions/action-form-body/custom-fields/probabilistic-sampler.tsx`](diffhunk://#diff-226efbc764ee3dc98d436cc3b76d524dc37a84cd0794bcd6c737178deb929d1fL1-R3): Updated to use `isEmpty` for checking empty values and added `useEffect` to handle initial empty state. [[1]](diffhunk://#diff-226efbc764ee3dc98d436cc3b76d524dc37a84cd0794bcd6c737178deb929d1fL1-R3) [[2]](diffhunk://#diff-226efbc764ee3dc98d436cc3b76d524dc37a84cd0794bcd6c737178deb929d1fL27-R35) ### Form validation improvements: * [`frontend/webapp/hooks/actions/useActionFormData.ts`](diffhunk://#diff-034891eac1659418ed1ceccc6d28858abafa1f6f5da688a2550123de5ee99841L2-R3): Integrated `isEmpty` for form validation and added a console log for debugging. [[1]](diffhunk://#diff-034891eac1659418ed1ceccc6d28858abafa1f6f5da688a2550123de5ee99841L2-R3) [[2]](diffhunk://#diff-034891eac1659418ed1ceccc6d28858abafa1f6f5da688a2550123de5ee99841R20-R21) [[3]](diffhunk://#diff-034891eac1659418ed1ceccc6d28858abafa1f6f5da688a2550123de5ee99841L28-R34) ### Updates to reusable components: * [`frontend/webapp/reuseable-components/input-table/index.tsx`](diffhunk://#diff-511aed49818334957716043c1273ee4e2a4c6bdc789f95e3cc2958f4cf603a1eR5): Used `isEmpty` to filter valid rows and handle empty values in the `InputTable` component. [[1]](diffhunk://#diff-511aed49818334957716043c1273ee4e2a4c6bdc789f95e3cc2958f4cf603a1eR5) [[2]](diffhunk://#diff-511aed49818334957716043c1273ee4e2a4c6bdc789f95e3cc2958f4cf603a1eL73-R74) [[3]](diffhunk://#diff-511aed49818334957716043c1273ee4e2a4c6bdc789f95e3cc2958f4cf603a1eL143-R146)
- Loading branch information