For now, we only want to allow lower case alphanumeric, numbers and `_`. Closes #272
26 lines
539 B
Go
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
|
|
}
|