This repository has been archived on 2025-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
miniauthold/vendor/github.com/go-passwd/validator/validator.go
kekskurse 7b5df08e45
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/playwright Pipeline was successful
ci/woodpecker/push/deplyoment Pipeline was successful
chore: password validation
2025-03-13 21:12:16 +01:00

29 lines
573 B
Go

package validator
import (
"errors"
)
// Validator represents set of password validators
type Validator []ValidateFunc
// New return new instance of Validator
func New(vfunc ...ValidateFunc) *Validator {
v := Validator{}
v = append(v, vfunc...)
return &v
}
// Validate the password
func (v *Validator) Validate(password string) error {
if len(*v) == 0 {
return errors.New("Validator must contains at least 1 validator function")
}
for _, passwordValidator := range *v {
err := passwordValidator(password)
if err != nil {
return err
}
}
return nil
}