fix: error if rule has no regex or path

This commit is contained in:
Henrique Dias
2024-11-28 16:57:10 +01:00
parent d418bd2661
commit 64bbdc7b15
2 changed files with 36 additions and 10 deletions
+4
View File
@@ -16,6 +16,10 @@ type Rule struct {
}
func (r *Rule) Validate() error {
if r.Regex == nil && r.Path == "" {
return errors.New("invalid rule: must either define a path of a regex")
}
if r.Regex != nil && r.Path != "" {
return errors.New("invalid rule: cannot define both regex and path")
}