How can I conditionally make a field required or not required?