diff options
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/utils.go')
-rw-r--r-- | vendor/github.com/mattermost/platform/model/utils.go | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/vendor/github.com/mattermost/platform/model/utils.go b/vendor/github.com/mattermost/platform/model/utils.go index 090644ec..e84d44f7 100644 --- a/vendor/github.com/mattermost/platform/model/utils.go +++ b/vendor/github.com/mattermost/platform/model/utils.go @@ -12,12 +12,14 @@ import ( "io" "io/ioutil" "net" + "net/http" "net/mail" "net/url" "regexp" "strconv" "strings" "time" + "unicode" goi18n "github.com/nicksnyder/go-i18n/i18n" "github.com/pborman/uuid" @@ -90,7 +92,7 @@ func AppErrorFromJson(data io.Reader) *AppError { if err == nil { return &er } else { - return NewLocAppError("AppErrorFromJson", "model.utils.decode_json.app_error", nil, "body: "+str) + return NewAppError("AppErrorFromJson", "model.utils.decode_json.app_error", nil, "body: "+str, http.StatusInternalServerError) } } @@ -106,18 +108,6 @@ func NewAppError(where string, id string, params map[string]interface{}, details return ap } -func NewLocAppError(where string, id string, params map[string]interface{}, details string) *AppError { - ap := &AppError{} - ap.Id = id - ap.params = params - ap.Message = id - ap.Where = where - ap.DetailedError = details - ap.StatusCode = 500 - ap.IsOAuth = false - return ap -} - var encoding = base32.NewEncoding("ybndrfg8ejkmcpqxot1uwisza345h769") // NewId is a globally unique identifier. It is a [A-Z0-9] string 26 @@ -283,11 +273,7 @@ func GetServerIpAddress() string { } func IsLower(s string) bool { - if strings.ToLower(s) == s { - return true - } - - return false + return strings.ToLower(s) == s } func IsValidEmail(email string) bool { @@ -492,3 +478,17 @@ func IsValidNumberString(value string) bool { return true } + +func IsValidId(value string) bool { + if len(value) != 26 { + return false + } + + for _, r := range value { + if !unicode.IsLetter(r) && !unicode.IsNumber(r) { + return false + } + } + + return true +} |