-
Notifications
You must be signed in to change notification settings - Fork 7
/
templates.go
134 lines (133 loc) · 13.2 KB
/
templates.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package validator
// ErrorTemplates returns a map of validation tags with error messages as html templates.
func ErrorTemplates() map[string]string {
return map[string]string{
"alpha": `{{.Namespace}} can only contain alphabetic characters`,
"alphanum": `{{.Namespace}} can only contain alphanumeric characters`,
"alphanumunicode": `{{.Namespace}} can only contain unicode alphanumeric characters`,
"alphaunicode": `{{.Namespace}} can only contain unicode alphabetic characters`,
"ascii": `{{.Namespace}} must contain only ascii characters`,
"base64": `{{.Namespace}} must be a valid Base64 string`,
"base64url": `{{.Namespace}} must be a valid Base64 URL string`,
"btc_addr": `{{.Namespace}} must be a valid Bitcoin address`,
"btc_addr_bech32": `{{.Namespace}} must be a valid bech32 Bitcoin address`,
"cidr": `{{.Namespace}} must contain a valid CIDR notation`,
"cidrv4": `{{.Namespace}} must contain a valid CIDR notation for an IPv4 address`,
"cidrv6": `{{.Namespace}} must contain a valid CIDR notation for an IPv6 address`,
"contains": `{{.Namespace}} must contain the text '{{.Param}}'`,
"containsany": `{{.Namespace}} must contain at least one of the following characters '{{.Param}}'`,
"containsrune": `{{.Namespace}} must contain the following '{{.Param}}'`,
"datauri": `{{.Namespace}} must contain a valid Data URI`,
"datetime": `{{.Namespace}} does not match the {{.Param}} format`,
"dir": `{{.Namespace}} must be a valid directory`,
"e164": `{{.Namespace}} must be a valid E.164 formatted phone number`,
"e164noplus": `{{.Namespace}} must be a valid E.164 formatted phone number without the leading '+' symbol`,
"ein": `{{.Namespace}} must be a valid US EIN tax code`,
"email": `{{.Namespace}} must be a valid email address`,
"endsnotwith": `{{.Namespace}} must not end with {{.Param}}`,
"endswith": `{{.Namespace}} must end with {{.Param}}`,
"eq": `{{.Namespace}} must be equal to {{.Param}}`,
"eqcsfield": `{{.Namespace}} must be equal to {{.Param}}`,
"eqfield": `{{.Namespace}} must be equal to {{.Param}}`,
"eth_addr": `{{.Namespace}} must be a valid Ethereum address`,
"excluded_with": `{{.Namespace}} must not be present or it must be empty`,
"excluded_with_all": `{{.Namespace}} must not be present or it must be empty`,
"excluded_without": `{{.Namespace}} must not be present or it must be empty`,
"excluded_without_all": `{{.Namespace}} must not be present or it must be empty`,
"excludes": `{{.Namespace}} cannot contain the text '{{.Param}}'`,
"excludesall": `{{.Namespace}} cannot contain any of the following characters '{{.Param}}'`,
"excludesrune": `{{.Namespace}} cannot contain the following '{{.Param}}'`,
"fieldcontains": `{{.Namespace}} must contain the field {{.Param}}`,
"fieldexcludes": `{{.Namespace}} must not contain the field {{.Param}}`,
"file": `{{.Namespace}} must be a valid file path`,
"fqdn": `{{.Namespace}} must be a Fully Qualified Domain Name (FQDN)`,
"gt": `{{.Namespace}} must {{ if (eq .Kind "String") }}be greater than {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain more than {{.Param}} items{{ else }}be greater than {{.Param}}{{ end }}{{ end }}`,
"gtcsfield": `{{.Namespace}} must {{ if (eq .Kind "String") }}be greater than {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain more than {{.Param}} items{{ else }}be greater than {{.Param}}{{ end }}{{ end }}`,
"gte": `{{.Namespace}} must {{ if (eq .Kind "String") }}be at least {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain at least {{.Param}} items{{ else }}be {{.Param}} or greater{{ end }}{{ end }}`,
"gtecsfield": `{{.Namespace}} must {{ if (eq .Kind "String") }}be at least {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain at least {{.Param}} items{{ else }}be {{.Param}} or greater{{ end }}{{ end }}`,
"gtefield": `{{.Namespace}} must {{ if (eq .Kind "String") }}be at least {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain at least {{.Param}} items{{ else }}be {{.Param}} or greater{{ end }}{{ end }}`,
"gtfield": `{{.Namespace}} must {{ if (eq .Kind "String") }}be greater than {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain more than {{.Param}} items{{ else }}be greater than {{.Param}}{{ end }}{{ end }}`,
"hexadecimal": `{{.Namespace}} must be a valid hexadecimal`,
"hexcolor": `{{.Namespace}} must be a valid HEX color`,
"hostname": `{{.Namespace}} must be a valid hostname as per RFC 952`,
"hostname_port": `{{.Namespace}} must be in the format DNS:PORT`,
"hostname_rfc1123": `{{.Namespace}} must be a valid hostname as per RFC 1123`,
"hsl": `{{.Namespace}} must be a valid HSL color`,
"hsla": `{{.Namespace}} must be a valid HSLA color`,
"html": `{{.Namespace}} must be valid HTML`,
"html_encoded": `{{.Namespace}} must be HTML-encoded`,
"ip": `{{.Namespace}} must be a valid IP address`,
"ip4_addr": `{{.Namespace}} must be a resolvable IPv4 address`,
"ip6_addr": `{{.Namespace}} must be a resolvable IPv6 address`,
"ip_addr": `{{.Namespace}} must be a resolvable IP address`,
"ipv4": `{{.Namespace}} must be a valid IPv4 address`,
"ipv6": `{{.Namespace}} must be a valid IPv6 address`,
"isbn": `{{.Namespace}} must be a valid ISBN number`,
"isbn10": `{{.Namespace}} must be a valid ISBN-10 number`,
"isbn13": `{{.Namespace}} must be a valid ISBN-13 number`,
"iscolor": `{{.Namespace}} must be a valid color`,
"isdefault": `{{.Namespace}} must not be present or it must be empty`,
"iso3166_1_alpha2": `{{.Namespace}} must be a valid iso3166-1 alpha-2 country code`,
"iso3166_1_alpha3": `{{.Namespace}} must be a valid iso3166-1 alpha-3 country code`,
"iso3166_1_alpha_numeric": `{{.Namespace}} must be a valid iso3166-1 alpha-numeric country code`,
"json": `{{.Namespace}} must be a valid json string`,
"latitude": `{{.Namespace}} must contain valid latitude coordinates`,
"len": `{{.Namespace}} must {{ if (eq .Kind "String") }}be {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain {{.Param}} items{{ else }}be equal to {{.Param}}{{ end }}{{ end }}`,
"longitude": `{{.Namespace}} must contain a valid longitude coordinates`,
"lowercase": `{{.Namespace}} must be a lowercase string`,
"lt": `{{.Namespace}} must {{ if (eq .Kind "String") }}be less than {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain less than {{.Param}} items{{ else }}be less than {{.Param}}{{ end }}{{ end }}`,
"ltcsfield": `{{.Namespace}} must {{ if (eq .Kind "String") }}be less than {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain less than {{.Param}} items{{ else }}be less than {{.Param}}{{ end }}{{ end }}`,
"lte": `{{.Namespace}} must {{ if (eq .Kind "String") }}be a maximum of {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain at maximum {{.Param}} items{{ else }}be {{.Param}} or less{{ end }}{{ end }}`,
"ltecsfield": `{{.Namespace}} must {{ if (eq .Kind "String") }}be a maximum of {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain at maximum {{.Param}} items{{ else }}be {{.Param}} or less{{ end }}{{ end }}`,
"ltefield": `{{.Namespace}} must {{ if (eq .Kind "String") }}be a maximum of {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain at maximum {{.Param}} items{{ else }}be {{.Param}} or less{{ end }}{{ end }}`,
"ltfield": `{{.Namespace}} must {{ if (eq .Kind "String") }}be less than {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain less than {{.Param}} items{{ else }}be less than {{.Param}}{{ end }}{{ end }}`,
"mac": `{{.Namespace}} must contain a valid MAC address`,
"max": `{{.Namespace}} must {{ if (eq .Kind "String") }}be a maximum of {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain at maximum {{.Param}} items{{ else }}be {{.Param}} or less{{ end }}{{ end }}`,
"min": `{{.Namespace}} must {{ if (eq .Kind "String") }}be at least {{.Param}} characters in length{{ else }}{{ if or (eq .Kind "Array") (eq .Kind "Map") (eq .Kind "String") }}contain at least {{.Param}} items{{ else }}be {{.Param}} or greater{{ end }}{{ end }}`,
"multibyte": `{{.Namespace}} must contain multibyte characters`,
"ne": `{{.Namespace}} must be different than {{.Param}}`,
"necsfield": `{{.Namespace}} must be different than {{.Param}}`,
"nefield": `{{.Namespace}} must be different than {{.Param}}`,
"number": `{{.Namespace}} must be a valid number`,
"numeric": `{{.Namespace}} must be a valid numeric value`,
"oneof": `{{.Namespace}} must be one of {{.Param}}`,
"printascii": `{{.Namespace}} must contain only printable ascii characters`,
"required": `{{.Namespace}} is required`,
"required_if": `{{.Namespace}} is required`,
"required_unless": `{{.Namespace}} is required`,
"required_with": `{{.Namespace}} is required`,
"required_with_all": `{{.Namespace}} is required`,
"required_without": `{{.Namespace}} is required`,
"required_without_all": `{{.Namespace}} is required`,
"rgb": `{{.Namespace}} must be a valid RGB color`,
"rgba": `{{.Namespace}} must be a valid RGBA color`,
"ssn": `{{.Namespace}} must be a valid US SSN number`,
"startsnotwith": `{{.Namespace}} must not start with {{.Param}}`,
"startswith": `{{.Namespace}} must start with {{.Param}}`,
"tcp4_addr": `{{.Namespace}} must be a valid IPv4 TCP address`,
"tcp6_addr": `{{.Namespace}} must be a valid IPv6 TCP address`,
"tcp_addr": `{{.Namespace}} must be a valid TCP address`,
"timezone": `{{.Namespace}} must be a valid time zone string`,
"udp4_addr": `{{.Namespace}} must be a valid IPv4 UDP address`,
"udp6_addr": `{{.Namespace}} must be a valid IPv6 UDP address`,
"udp_addr": `{{.Namespace}} must be a valid UDP address`,
"unique": `{{.Namespace}} must contain unique values`,
"unix_addr": `{{.Namespace}} must be a resolvable UNIX address`,
"uppercase": `{{.Namespace}} must be an uppercase string`,
"uri": `{{.Namespace}} must be a valid URI`,
"url": `{{.Namespace}} must be a valid URL`,
"url_encoded": `{{.Namespace}} must be URL-encoded`,
"urn_rfc2141": `{{.Namespace}} must be a valid URN as per RFC 2141`,
"usstate": `{{.Namespace}} must be a valid 2-letter US state`,
"usterritory": `{{.Namespace}} must be a valid 2-letter US territory`,
"uuid": `{{.Namespace}} must be a valid UUID`,
"uuid3": `{{.Namespace}} must be a valid version 3 UUID`,
"uuid3_rfc4122": `{{.Namespace}} must be a valid version 3 UUID as per RFC 4122`,
"uuid4": `{{.Namespace}} must be a valid version 4 UUID`,
"uuid4_rfc4122": `{{.Namespace}} must be a valid version 4 UUID as per RFC 4122`,
"uuid5": `{{.Namespace}} must be a valid version 5 UUID`,
"uuid5_rfc4122": `{{.Namespace}} must be a valid version 5 UUID as per RFC 4122`,
"uuid_rfc4122": `{{.Namespace}} must be a valid UUID as per RFC 4122`,
"zipcode": `{{.Namespace}} must be a valid US ZIP code`,
}
}