mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-22 04:41:16 +00:00
21 lines
580 B
Go
21 lines
580 B
Go
package helpers
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/Luzifer/go_helpers/v2/fieldcollection"
|
|
)
|
|
|
|
// SchemaValidateTemplateField contains a ValidateOpt for the
|
|
// fieldcollection schema validator to validate template fields
|
|
func SchemaValidateTemplateField(tplValidator func(string) error, fields ...string) fieldcollection.ValidateOpt {
|
|
return func(f, _ *fieldcollection.FieldCollection) (err error) {
|
|
for _, field := range fields {
|
|
if err = tplValidator(f.MustString(field, Ptr(""))); err != nil {
|
|
return fmt.Errorf("validating %s: %w", field, err)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
}
|