Compare commits
No commits in common. "cf26a112f23a616bb13118669db36fb9dbe72bae" and "e88fb5c1daf192029b35a62fef000f40c7b9cc99" have entirely different histories.
cf26a112f2
...
e88fb5c1da
@ -1,69 +0,0 @@
|
||||
package osutils
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func UuidValidate(uuid string) error {
|
||||
if len(uuid) != 36 {
|
||||
return errors.New("uuid length not valid")
|
||||
}
|
||||
|
||||
// validate first 8 octets
|
||||
for i := 0; i < 8; i++ {
|
||||
if !(unicode.IsLetter(rune(uuid[i])) || unicode.IsDigit(rune(uuid[i]))) && uuid[i] == '-' {
|
||||
return errors.New("uuid first 8 octets not valid")
|
||||
}
|
||||
}
|
||||
|
||||
// validate separator
|
||||
if uuid[8] != '-' {
|
||||
return errors.New("uuid separator not valid")
|
||||
}
|
||||
|
||||
// validate second 4 octets
|
||||
for i := 9; i < 13; i++ {
|
||||
if !(unicode.IsLetter(rune(uuid[i])) || unicode.IsDigit(rune(uuid[i]))) && uuid[i] == '-' {
|
||||
return errors.New("uuid second 4 octets not valid")
|
||||
}
|
||||
}
|
||||
|
||||
// validate separator
|
||||
if uuid[13] != '-' {
|
||||
return errors.New("uuid separator not valid")
|
||||
}
|
||||
|
||||
// validate third 4 octets
|
||||
for i := 14; i < 18; i++ {
|
||||
if !(unicode.IsLetter(rune(uuid[i])) || unicode.IsDigit(rune(uuid[i]))) && uuid[i] == '-' {
|
||||
return errors.New("uuid third 4 octets not valid")
|
||||
}
|
||||
}
|
||||
|
||||
// validate separator
|
||||
if uuid[18] != '-' {
|
||||
return errors.New("uuid separator not valid")
|
||||
}
|
||||
|
||||
// validate fourth 4 octets
|
||||
for i := 19; i < 23; i++ {
|
||||
if !(unicode.IsLetter(rune(uuid[i])) || unicode.IsDigit(rune(uuid[i]))) && uuid[i] == '-' {
|
||||
return errors.New("uuid fourth 4 octets not valid")
|
||||
}
|
||||
}
|
||||
|
||||
// validate separator
|
||||
if uuid[23] != '-' {
|
||||
return errors.New("uuid separator not valid")
|
||||
}
|
||||
|
||||
// validate fourth 4 octets
|
||||
for i := 24; i < 36; i++ {
|
||||
if !(unicode.IsLetter(rune(uuid[i])) || unicode.IsDigit(rune(uuid[i]))) && uuid[i] == '-' {
|
||||
return errors.New("uuid fifth 12 octets not valid")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user