wisski-cloud-distillery/internal/config/validators/collection.go
Tom Wiesing 945329a080
Move to yaml-based configuration
This commit updates the configuration to be yaml-based and updates the
configuration to read in a yaml file.
2023-02-25 09:14:56 +01:00

32 lines
1,004 B
Go

package validators
import (
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/validator"
)
// New creates a new set of standard validators for the configuration
func New(env environment.Environment) validator.Collection {
coll := make(validator.Collection)
validator.Add(coll, "nonempty", ValidateNonempty)
validator.Add(coll, "directory", func(value *string, dflt string) error {
return ValidateDirectory(env, value, dflt)
})
validator.Add(coll, "file", func(value *string, dflt string) error {
return ValidateFile(env, value, dflt)
})
validator.Add(coll, "domain", ValidateDomain)
validator.AddSlice(coll, "domains", ",", ValidateDomain)
validator.Add(coll, "https", ValidateHTTPSURL)
validator.Add(coll, "slug", ValidateSlug)
validator.Add(coll, "email", ValidateEmail)
validator.Add(coll, "positive", ValidatePositive)
validator.Add(coll, "port", ValidatePort)
validator.Add(coll, "duration", ValidateDuration)
return coll
}