Imagine that I have an endpoint that accepts optional MyParam string array attribute.
How to check it if it's null or empty with most basic way - Data Annotations would be the best.
https://stackoverflow.com/questions/ask?MyParam=
[Required]is not an option as parameter has to be optional[StringLength]with MinimumLength doesn't work[MinLength]doesn't work at all[RegularExpression(@"\S+")]doesn't work at all
Update: I want to do it on string array not just string, sorry about confusion. Hope this help to justify why above DataAnnotations don't work.
[Required]and Check ifModelState.IsValid(), if its not return an error from the controller.IsValid()just checks if it was provided or not - still can accept empty string.