From 78b207a40436d0c15a2b806171914d802cd20661 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Tue, 10 Apr 2012 20:58:13 -0400 Subject: tests passing --- util.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'util.go') diff --git a/util.go b/util.go index 6b5049e..c8ed617 100644 --- a/util.go +++ b/util.go @@ -1,5 +1,12 @@ package main +// Minimal Error type... is there a better way? +type Error string + +func (e Error) Error() string { + return string(e) +} + type EmailAddress string type Password string type Url string @@ -7,3 +14,19 @@ type Url string // "Slug" string with limited ASCII character set, good for URLs. // Lowercase alphanumeric plus '_' allowed. type ShortName string + +func isShortName(s string) bool { + for i, r := range s { + switch { + case '0' <= r && '9' >= r && i > 0: + continue + case 'a' <= r && 'z' >= r: + continue + case r == '_' && i > 0: + continue + default: + return false + } + } + return true +} -- cgit v1.2.3