Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能否增加个方法用于替换默认的验证器插件validator.Do #289

Open
LonelyPale opened this issue May 13, 2023 · 4 comments
Open
Labels
question Further information is requested

Comments

@LonelyPale
Copy link

我想用其他第三方验证器go-tagexpr或者自己的验证器来替换默认的validator.Do,虽然可以用func Register(cb callback)追加自己的验证器插件,但运行时默认的validator.Do都会被执行一遍,虽然不影响结果,但总感觉不够完美。好吧,我有强迫症😀😀😀

@jiangz222
Copy link
Collaborator

Hi, why should we import other validator ? any feature is not supported by the origin one ?

@jiangz222 jiangz222 added the question Further information is requested label May 24, 2023
@jiangz222
Copy link
Collaborator

jiangz222 commented May 24, 2023

如果是想做的更灵活,你的实现又显得有些定制

@LonelyPale
Copy link
Author

我们的想法是让用户可以自己决定使用什么验证器(至少可以选择一些流行的库),validator本身也是第三方导入的库,使用go-tagexpr是因为我们在一些旧的业务系统中已经使用了它,现在需要升级老的MongoDB Driver,我们打算用qmgo替换mgo,如果能完美兼容其他验证器,我们就可以减少很多替换验证器的工作了。
现在的实现使用断言类型显得有些定制,如果我把第三方验证器做一层浅的封装,再抽象出一个验证的接口来使用,你觉得这个方案如何?如果可行我就这样改一版。

@jiangz222
Copy link
Collaborator

jiangz222 commented May 25, 2023

嗯,如果要做到插件式,应该是把所有的实现都接口化,然后各自实现
不过其实不如趁着次切到validator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants