Create requiredIf method 

Create a requiredIf method that takes a function as first argument, the field is required if the function returns true.

Use case: fields that are required only if a checkbox or a radio button is checked.