authelia/internal/configuration/validator/keys.go
Amir Zarrinkafsh 1600e0f7da
[CI] Add wsl linter (#980)
* [CI] Add wsl linter

* Implement wsl recommendations

Co-authored-by: Clément Michaud <clement.michaud34@gmail.com>
2020-05-05 21:35:32 +02:00

33 lines
696 B
Go

package validator
import (
"errors"
"fmt"
"github.com/authelia/authelia/internal/configuration/schema"
"github.com/authelia/authelia/internal/utils"
)
// ValidateKeys determines if a provided key is valid.
func ValidateKeys(validator *schema.StructValidator, keys []string) {
var errStrings []string
for _, key := range keys {
if utils.IsStringInSlice(key, validKeys) {
continue
}
if err, ok := specificErrorKeys[key]; ok {
if !utils.IsStringInSlice(err, errStrings) {
errStrings = append(errStrings, err)
}
} else {
validator.Push(fmt.Errorf("config key not expected: %s", key))
}
}
for _, err := range errStrings {
validator.Push(errors.New(err))
}
}