Validate validates ScopeEnumRule
(msg lint.Commit)
| 41 | |
| 42 | // Validate validates ScopeEnumRule |
| 43 | func (r *ScopeEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool) { |
| 44 | if msg.Scope() == "" { |
| 45 | if r.AllowEmpty { |
| 46 | return nil, true |
| 47 | } |
| 48 | errMsg := fmt.Sprintf("empty scope is not allowed, you can use one of %v", r.Scopes) |
| 49 | return lint.NewIssue(errMsg), false |
| 50 | } |
| 51 | |
| 52 | isFound := search(r.Scopes, msg.Scope()) |
| 53 | if isFound { |
| 54 | return nil, true |
| 55 | } |
| 56 | |
| 57 | errMsg := fmt.Sprintf("scope '%s' is not allowed, you can use one of %v", msg.Scope(), r.Scopes) |
| 58 | return lint.NewIssue(errMsg), false |
| 59 | } |