go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.05k stars 1.29k forks source link

Is it possible to register custom validation function directly returning errors? #1278

Open WoWsj opened 3 weeks ago

WoWsj commented 3 weeks ago

Package version eg. v9, v10:

v10

Issue, Question or Enhancement:

Hello folks,

I'd like to validate requests in HTTP server. I want to tell clients why you failed the request.

In some cases, there are several conditions to validate. However, current RegisterValidation method for *Validate accept function returning bool value, It means that it cannot represent why validation failed, only tell whether it succeeds or not.

So,

Q. Is there any way to return errors directly?

noornee commented 2 weeks ago

need this fr. turns out it isnt going to be implemented till v11 #669