validateRule validates a matching rule, including checking its basic structure and criteria. Parameters: - rule: The rule to validate. Returns an error if the rule or any of its criteria are invalid.
(rule *model.MatchingRule)
| 1196 | // - rule: The rule to validate. |
| 1197 | // Returns an error if the rule or any of its criteria are invalid. |
| 1198 | func (s *LedgerForge) validateRule(rule *model.MatchingRule) error { |
| 1199 | // Validate basic structure of the rule. |
| 1200 | if err := s.validateRuleBasics(rule); err != nil { |
| 1201 | return err |
| 1202 | } |
| 1203 | |
| 1204 | // Validate each individual criterion. |
| 1205 | for _, criteria := range rule.Criteria { |
| 1206 | if err := s.validateCriteria(criteria); err != nil { |
| 1207 | return err |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | return nil |
| 1212 | } |
| 1213 | |
| 1214 | // validateRuleBasics checks that the rule has a valid name and at least one criterion. |
| 1215 | // Parameters: |
no test coverage detected