Files
brianmcgee 1466e50384
buildbot/nix-eval Build done.
buildbot/nix-build Build done.
feat: restrict characters in file names
For now, we only want to allow lower case alphanumeric, numbers and `_`.

Closes #272
2026-01-23 17:22:52 +00:00

26 lines
539 B
Go

package config
import (
"fmt"
"git.clan.lol/clan/data-mesher/pkg/crypto"
"git.clan.lol/clan/data-mesher/pkg/model"
)
type Files map[string][]*crypto.PublicKey
func (f Files) Validate() error {
if len(f) == 0 {
return fmt.Errorf("%w: at least one file should be configured", ErrInvalidConfig)
}
// validate the file names
for name := range f {
if err := model.ValidateName(name); err != nil {
return fmt.Errorf("%w: file names must match '%s': %s", ErrInvalidConfig, model.NameRegex.String(), name)
}
}
return nil
}