I have this object state which I have intialized it as initialSegement
I have created this component when I set the state of every field startDate, endDate etc and all is working fine there.
I want to create this function called validateSegement which will be boolean. If this function returns true, then the button to add a segment will be enabled.
I have created this function, but unfortunately is not dynamic.
The issue is that these fields are configured dynamically by the user if they're mandatory or not. So I want to find a way of doing this by first checking if fields are mandatory and second checking if the mandatory fields are empty or not.
I can find out if the fields are mandatory from a response from the backend, which for this case I will suppose the response is like this: