-
Notifications
You must be signed in to change notification settings - Fork 4
RequiredEmptyWhen
Michal Altair Valášek edited this page May 28, 2024
·
4 revisions
Complements the RequiredWhen attribute. Forces property to have empty value when other property has specific value.
[RequiredEmptyWhen("OtherProperty", "value")] // property is required to be empty when OtherProperty == "value"
[RequiredEmptyWhen("OtherProperty", "value", NegateCondition = true)] // property is required to be empty when OtherProperty != "value"Please note: The default error message does not mention the master condition (it says Field {0} is required to be empty, not Field {0} is required to be empty when some conditions are met). It's recommended to override the message to be more specific to your model.