Some checks failed
Build Docker Image / Build-Docker-Image (push) Failing after 4m58s
14 lines
367 B
Go
14 lines
367 B
Go
package service
|
|
|
|
import "fmt"
|
|
|
|
func validateString(value string, fieldName string) error {
|
|
if value == "" {
|
|
return fmt.Errorf("field \"%s\" needs to be set: %w", fieldName, ErrBadRequest)
|
|
} else if !safeInputRegex.MatchString(value) {
|
|
return fmt.Errorf("use only letters, dashes and spaces for \"%s\": %w", fieldName, ErrBadRequest)
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|