Validate validates FooterEnumRule
(msg lint.Commit)
| 32 | |
| 33 | // Validate validates FooterEnumRule |
| 34 | func (r *FooterEnumRule) Validate(msg lint.Commit) (*lint.Issue, bool) { |
| 35 | var invalids []string |
| 36 | |
| 37 | for _, note := range msg.Notes() { |
| 38 | isFound := search(r.Tokens, note.Token()) |
| 39 | if !isFound { |
| 40 | invalids = append(invalids, note.Token()) |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | if len(invalids) == 0 { |
| 45 | return nil, true |
| 46 | } |
| 47 | |
| 48 | desc := fmt.Sprintf("you can use one of %v", r.Tokens) |
| 49 | info := fmt.Sprintf("[%s] tokens are not allowed", strings.Join(invalids, ", ")) |
| 50 | return lint.NewIssue(desc, info), false |
| 51 | } |