support custom FieldLevel error message when use RegisterValidation
Package version eg. v8, v9:
v9
Issue, Question or Enhancement:
validator.StructLevel type, has method ReportError(....)
but, validator.FieldLevel type can't not support set some custom error message. that are only use const translation map or const string "Key: '%s' Error:Field validation for '%s' failed on the '%s' tag" . Can not relation with input value!
Code sample, to showcase or reproduce:
Hey @RelicOfTesla yes I'm investigating different options that may make it easier for custom translations, however having said that all information should be available on the returned errors to create custom error messages in the meantime and the originally intended way to customize error messages.
Yeah, definitely need Field level custom tag to return error rather than bool, to report better error message to user. Please consider of this sir.
custom validation is for area where normal tags fail. Image scenario that during validation we connect to database and connection failed. We return false, but user has nothing wrong with the data. Or complex situation that check multiple field in one validator like variation to exclude_if error can be even on different field. Ability to reqister function (error) or (bool,error) will resolve this. Alternative solution need struct validation and complex crawling function to be able reach ReportError