Dynamically update rules based on Select option

Hello,

Is it possible to change required to true of false for other form fields based on Select option ?

For example

I have a Select field named service with options hourly and point-to-point
and I have some fields like number_of_hours, point_from, point_to

the number_of_hours is required when hourly is selected
point_from is required all the time
point_to is required when point-to-point is selected.

It works great with the normal validation rules like requiredIf('service','hourly');
but I am trying to make it work a bit dynamically using the config values which users can set themselves for their forms.

so basically what I am trying to do is to set the required rule within afterStateUpdated for Select field.

Please check the image attached.

Thank you
image.png
Was this page helpful?