MiniValidation
MiniValidation copied to clipboard
Consider returning A List or Enumerable for errors?
Currently 'TryValidate' method returns IDictionary<string, string[]>
. If we look at the implementation of the 'TryValidate' method, it first creates Dictionary<string, List<string>>
then it maps it to Dictionary<string, string[]>
using the ToArray
method. But can't it just return the Dictionary<string, List<string>>
? What's the problem with it? Mapping it using ToArray
causes it to create new arrays,
It's not like arrays are immutable. For immutable behavior IEnumerable
or even better IReadOnlyCollection
would be much better as they won't allocate new collections.
Maybe I'm missing something on the intention of returning arrays. Let me know.