holden-cpu commented on code in PR #1519:
URL:
https://github.com/apache/servicecomb-service-center/pull/1519#discussion_r2309291597
##########
server/service/validator/validator.go:
##########
@@ -32,3 +50,77 @@ func baseCheck(v interface{}) error {
}
return nil
}
+
+func customValidate(v interface{}, targetValidators ...string) error {
+ if len(customValidators) == 0 {
+ return nil
+ }
+ for _, validatorName := range targetValidators {
+ validator, exists := customValidators[validatorName]
+ if !exists {
+ log.Info(fmt.Sprintf("validator:%s is not
registered,skip", validatorName))
+ continue
+ }
+ validate, err := validator.Validate(v)
+ if err != nil {
+ return err
+ }
+ if !validate {
+ return errors.New(fmt.Sprintf("Validate
failed,validator:%s", validatorName))
Review Comment:
不用,遇到校验不通过直接返回即可
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]