Files
validate/uuid.go
T

19 lines
337 B
Go
Raw Normal View History

2023-10-06 11:58:24 +01:00
package validate
import (
"errors"
"regexp"
)
var uuidRegexp = regexp.MustCompile("^[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}$")
// UUID validates a UUID string.
// The UUID must be formatted with separators.
func UUID(value string) error {
if !uuidRegexp.MatchString(value) {
return errors.New("Invalid UUID")
}
return nil
}