add workspace, validation

This commit is contained in:
Aneurin Barker Snook
2023-10-06 11:58:24 +01:00
commit f41d6f248a
5 changed files with 98 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
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
}