2021-01-20 12:07:40 +00:00
|
|
|
package validator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
2022-02-28 03:15:01 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/utils"
|
2021-01-20 12:07:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ValidateTheme validates and update Theme configuration.
|
2022-02-28 03:15:01 +00:00
|
|
|
func ValidateTheme(config *schema.Configuration, validator *schema.StructValidator) {
|
|
|
|
if config.Theme == "" {
|
|
|
|
config.Theme = "light"
|
2021-06-01 04:09:50 +00:00
|
|
|
}
|
|
|
|
|
2022-02-28 03:15:01 +00:00
|
|
|
if !utils.IsStringInSlice(config.Theme, validThemeNames) {
|
2023-04-13 10:58:18 +00:00
|
|
|
validator.Push(fmt.Errorf(errFmtThemeName, strJoinOr(validThemeNames), config.Theme))
|
2021-01-20 12:07:40 +00:00
|
|
|
}
|
|
|
|
}
|