This attribute would ensure the length of a string, array, or IEnumerable is not greater than a maximum length.
Determine Maximum Length Value
The maximum length should be determined firstly by the attribute's own value via the constructor or property. Should the attribute not specify a value, a MaxLengthAttribute
attribute would be sought. And lastly, when the value being mutated is a string, the StringLengthAttribute
will be used.
EnsureMinLength
An equivalent attribute for minimum length will not be made. Such an attribute would be too opinionated as it would need to accept a value/s that would be used fill any empty positions. Instead a IMutableObject
interface or custom MutationAttribute
is more suitable.