FluentValidation.AutoValidation icon indicating copy to clipboard operation
FluentValidation.AutoValidation copied to clipboard

ICollection<T> support

Open tomasz-soltysik opened this issue 1 year ago • 3 comments

Current implementation checks if parameter type is class. This check fails if we use ICollection<T> as parameter type. ASP.NET is able to deserialize to it, it is also possible to create and register IValidator<ICollection<T>>.

What is the reason for not allowing such interfaces to be auto-validated?

In PR with refactor of IsCustomType (#32) it is proposed to change to even more strict, by disallowing anything that implements IEnumerable, which I would consider breaking change and would like to understand the reason for it.

tomasz-soltysik avatar Jan 09 '24 15:01 tomasz-soltysik

Hi @tomasz-soltysik, thanks for expressing your concerns! I haven't really gotten around to reviewing the PR that you mentioned. If the merging of said PR would result in a breaking change it will not be something that will be released in the v1.x versions. If a breaking change would slip through the cracks it is something I would revert right away.

Regarding the validation of ICollection<T> and variants; great point, I guess if FluentValidation supports validation for it we should support it as well. If anything I am of the opinion that the IsCustomType check should be more relaxed instead of more strict. I am also reluctant to relaxing the IsCustomType check in the v1.x versions since you also could argue that that would also be considered a breaking change :).

mvdgun avatar Jan 09 '24 15:01 mvdgun

@mvdgun @tomasz-soltysik I added another commit to remove the check for IEnumerable

Tihomirov-Vasiliy avatar Jan 15 '24 13:01 Tihomirov-Vasiliy

Moved this issue to the v2.0 milestone

mvdgun avatar Dec 04 '24 21:12 mvdgun