feat: implement ValidatorValuer interface feature#1416
feat: implement ValidatorValuer interface feature#1416nodivbyzero merged 1 commit intogo-playground:masterfrom
Conversation
7222de7 to
a4b2773
Compare
zemzale
left a comment
There was a problem hiding this comment.
The good looks good.
My only concerns would maybe be the naming of the interface and it's function.
a4b2773 to
2996074
Compare
2996074 to
62dc169
Compare
|
Do we have any updates on this? |
62dc169 to
05867e9
Compare
Still waiting for review by @go-playground/validator-maintainers |
zemzale
left a comment
There was a problem hiding this comment.
The code itself is good.
Just not fully sure about the whole thing just as written in the discussion, that this is very implicit API that would tie in the validator with your types.
Would want more opinions on this before merging.
|
Very much looking forward to this feature. @zemzale Any updates here? |
|
Is this issue just waiting for more input before merging? I think this is a fine implementation for the problem. I've had to work around this so far and this simple fix would help a lot actually. Seems the concern is that using an interface on your type would make you have to be aware of the validation framework for that type, but I'd argue that in these custom cases you have to do that any way. Especially without this fix you have to put in extra validator code for that type. Granted, it doesn't have to be directly tied to that type. But if that's an issue, you don't have to use it. So I vote to push this through. Thanks for the fix @thommeo and for the time to review @zemzale |
|
Sorry for joining the conversation late. |
|
@thommeo are you able to add the documentation? or if they are unable to, is this something maintainers can add in a separate PR @nodivbyzero ? |
|
@kayla-barenz-kr Yep, we can add it in a separate PR 👍 |
Add documentation for the Valuer interface introduced in go-playground#1416. - add Valuer interface section and example snippet in doc.go - add a new runnable example at _examples/valuer/ main.go - add Valuer Interface entry in README examples list Refs go-playground#1538
Problem
In order to have custom type validations for generic types, every possible type has to be registered with
RegisterCustomTypeFuncto return the underlying type. It is especially relevant for nullable types e.g.sql.Null[T].Discussed here: #1232
Fixes Or Enhances
ValidatorValuerinterface.Example:
Make sure that you've checked the boxes below before you submit PR:
@go-playground/validator-maintainers