RequiredFieldsAttribute
namespace: MvcControlsToolkit.Core.DataAnnotations
Th RequiredFieldsAttribute
is a model level validation attribute.
It declares a list of properties that are require and, in case they are IEnumerables, also not empty.
Being a model level attribute it doesn't imply a client side input validation,
so validation is performed just on the server side. Therefore, it is usefull either on
DTO classes that are not ViewModels, or to declare not empty IEnumerables, or not null complex objects, since
in all other cases the RequiredAttribute
applied directly on each property
has more advantages.
Several RequiredFieldsAttribute
with different settings may be applied to the same class.
It has two properties to be configured:
- Fields
- A string containing all required property names separated by commas ','.
- RejectEmptyIEnumerables
- A boolean that, when set, declares all IEnumerables in the Fields list must be also not emprty.