diff options
| author | bnewbold <bnewbold@robocracy.org> | 2012-04-10 20:58:13 -0400 | 
|---|---|---|
| committer | bnewbold <bnewbold@robocracy.org> | 2012-04-11 10:58:08 -0400 | 
| commit | 78b207a40436d0c15a2b806171914d802cd20661 (patch) | |
| tree | 730d02b32e5d54b2512a319d7ced34ad8ce3aacf /util.go | |
| parent | 3c7a4451e62d27bbe9dc8eb2c16e2ff5607d1b04 (diff) | |
| download | bommom-78b207a40436d0c15a2b806171914d802cd20661.tar.gz bommom-78b207a40436d0c15a2b806171914d802cd20661.zip  | |
tests passing
Diffstat (limited to 'util.go')
| -rw-r--r-- | util.go | 23 | 
1 files changed, 23 insertions, 0 deletions
@@ -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 +}  | 
