Skip to content

Commit

Permalink
improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenX2018 committed Jul 13, 2020
1 parent 190d69f commit a3cfc8e
Showing 1 changed file with 63 additions and 2 deletions.
65 changes: 63 additions & 2 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ var builtinMessages = map[string]string{
"isInts": "{field} value must be an int slice",
"isUint": "{field} value must be an unsigned integer(>= 0)",
// type check: string
"isString": "{field} value must be an string",
"isString1": "{field} value must be an string and min length is %d", // has min len check
"isString": "{field} value must be a string",
"isString1": "{field} value must be a string and min length is %d", // has min len check
// length
"minLength": "{field} min length is %d",
"maxLength": "{field} max length is %d",
Expand Down Expand Up @@ -146,6 +146,67 @@ var builtinMessages = map[string]string{
"lteField": "{field} value should be less than or equal to field %s",
"gtField": "{field} value must be greater the field %s",
"gteField": "{field} value should be greater or equal to field %s",
// data type
"bool": "{field} value must be a bool",
"float": "{field} value must be a float",
"slice": "{field} value must be a slice",
"map": "{filed} value must be a map",
"array": "{filed} value must be an array",
"strings": "{filed} value must be a []string",
"notIn": "{field} value must not in the given enum list %d",
//
"contains": "{filed} value does not contain this %s",
"notContains": "{filed} value contains the given %s",
"startsWith": "{filed} value does not start with the given %s",
"endsWith": "{filed} value does not end with the given %s",
"email": "{filed} value is invalid mail",
"regex": "{filed} value does not pass regex check",
"file": "{filed} value must be a file",
"image": "{filed} value must be an image",
// date
"date": "{filed} value should be an date string",
"gtDate": "{field} value should be after %s",
"ltDate": "{field} value should be before %s",
"gteDate": "{field} value should be after or equal to %s",
"lteDate": "{field} value should be before or equal to %s",
// check char
"hasWhitespace": "{field} value should contains spaces",
"ascii": "{field} value should be an ASCII string",
"alpha": "{field} value contains only alpha char",
"alphaNum": "{field} value contains only alpha char and num",
"alphaDash": "{field} value contains only letters,num,dashes (-) and underscores (_)",
"multiByte": "{field} value should be a multiByte string",
"base64": "{field} value should be a base64 string",
"dnsName": "{field} value should be a DNS string",
"dataURI": "{field} value should be a DataURL string",
"empty": "{field} value should be empty",
"hexColor": "{field} value should be a color string in hexadecimal",
"hexadecimal": "{field} value should be a hexadecimal string",
"json": "{field} value should be a json string",
"lat": "{field} value should be latitude coordinates",
"lon": "{field} value should be longitude coordinates",
"num": "{field} value should be a num (>=0) string.",
"mac": "{field} value should be mac string",
"cnMobile": "{field} value should be string of Chinese 11-digit mobile phone numbers",
"printableASCII": "{field} value should be a printable ASCII string",
"rgbColor": "{field} value should be a RGB color string",
"fullURL": "{field} value should be a complete URL string",
"full": "{field} value should be a URL string",
"ip": "{field} value should be an ip (v4 or v6) string",
"ipv4": "{field} value should be an ipv4 string",
"ipv6": "{field} value should be an ipv6 string",
"CIDR": "{field} value should be a CIDR string",
"CIDRv4": "{field} value should be a CIDRv4 string",
"CIDRv6": "{field} value should be a CIDRv6 string",
"uuid": "{field} value should be a UUID string",
"uuid3": "{field} value should be a UUID3 string",
"uuid4": "{field} value should be a UUID4 string",
"uuid5": "{field} value should be a UUID5 string",
"filePath": "{field} value should be an existing file path",
"unixPath": "{field} value should be a unix path string",
"winPath": "{field} value should be a windows path string",
"isbn10": "{field} value should be a isbn10 string",
"isbn13": "{field} value should be a isbn13 string",
}

// AddBuiltinMessages add builtin messages
Expand Down

0 comments on commit a3cfc8e

Please sign in to comment.