-
Notifications
You must be signed in to change notification settings - Fork 3
/
messages.go
32 lines (30 loc) · 1 KB
/
messages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package validate
// Messages for the checkers; this can be changed for i18n.
var (
MessageRequired = "must be set"
MessageDomain = "must be a valid domain"
MessageURL = "must be a valid url"
MessageEmail = "must be a valid email address"
MessageIPv4 = "must be a valid IPv4 address"
MessageHexColor = "must be a valid color code"
MessageLenLonger = "must be longer than %d characters"
MessageLenShorter = "must be shorter than %d characters"
MessageExclude = "cannot be ‘%s’"
MessageInclude = "must be one of ‘%s’"
MessageInteger = "must be a whole number"
MessageBool = "must be a boolean"
MessageDate = "must be a date as ‘%s’"
MessagePhone = "must be a valid phone number"
MessageRangeHigher = "must be %d or higher"
MessageRangeLower = "must be %d or lower"
)
func getMessage(in []string, def string) string {
switch len(in) {
case 0:
return def
case 1:
return in[0]
default:
panic("can only pass one message")
}
}