IsUuid requires that the string is a valid UUID
(val interface{})
| 30 | |
| 31 | // IsUuid requires that the string is a valid UUID |
| 32 | func IsUuid(val interface{}) error { |
| 33 | if str, ok := val.(string); ok { |
| 34 | if _, err := uuid.Parse(str); err != nil { |
| 35 | return fmt.Errorf("not a valid UUID") |
| 36 | } |
| 37 | } else { |
| 38 | // otherwise we cannot convert the value into a string and cannot perform check |
| 39 | return fmt.Errorf("cannot check value on response of type %v", reflect.TypeOf(val).Name()) |
| 40 | } |
| 41 | |
| 42 | // the input is fine |
| 43 | return nil |
| 44 | } |
| 45 | |
| 46 | func IsExistingFile(val interface{}) error { |
| 47 | if str, ok := val.(string); ok { |
no outgoing calls