Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 committed Feb 27, 2020
1 parent b83794b commit 3839931
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/pb/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package pb

import (
"fmt"

"github.com/fagongzi/gateway/pkg/plugin"
"regexp"

"github.com/fagongzi/gateway/pkg/expr"
"github.com/fagongzi/gateway/pkg/pb/metapb"
"github.com/fagongzi/gateway/pkg/plugin"
)

// ValidateRouting validate routing
Expand Down Expand Up @@ -69,6 +69,17 @@ func ValidateAPI(value *metapb.API) error {
return err
}
}

for _, v := range n.Validations {
for _, r := range v.Rules {
if r.RuleType == metapb.RuleRegexp {
_, err := regexp.Compile(r.Expression)
if err != nil {
return err
}
}
}
}
}

return nil
Expand Down

0 comments on commit 3839931

Please sign in to comment.