Move rule target builders into the correct locations.

This commit is contained in:
Anna Rose Wiggins 2025-08-11 20:53:01 -04:00
parent 9e4062ba30
commit 33b62496a3
17 changed files with 198 additions and 194 deletions

View file

@ -3,6 +3,7 @@ package mappingrules
import (
"errors"
"fmt"
"slices"
"strings"
"git.annabunches.net/annabunches/joyful/internal/configparser"
@ -60,3 +61,19 @@ func NewRule(config configparser.RuleConfig, pDevs map[string]Device, vDevs map[
return newRule, nil
}
// validateModes checks the provided modes against a larger subset of modes (usually all defined ones)
// and returns false if any of the modes are not defined.
func validateModes(modes []string, allModes []string) bool {
if len(modes) == 0 {
return true
}
for _, mode := range modes {
if !slices.Contains(allModes, mode) {
return false
}
}
return true
}