-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
73 lines (56 loc) · 2.22 KB
/
errors.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
package vld
const (
// ErrValidation when validation adds some field error
// Used in String, StrPtr, Number
ErrValidation = "ErrValidation"
// ErrRequired when value is required
ErrRequired = "ErrRequired"
// ErrStringGT when length is not greater than
// Used in String, StrPtr
ErrStringGT = "ErrStringGT"
// ErrStringGTE when length is not greater or equal than
ErrStringGTE = "ErrStringGTE"
// ErrStringLT when length is not smaller than
ErrStringLT = "ErrStringLT"
// ErrStringLTE when length is not smaller or equal than
ErrStringLTE = "ErrStringLTE"
// ErrStringLength when value is out of length
ErrStringLength = "ErrStringLength"
// ErrStringLen when value is out of len
ErrStringLen = "ErrStringLen"
// ErrStringMatch when value does not match with regex
ErrStringMatch = "ErrStringMatch"
// ErrStringOneOf value is not one of
ErrStringOneOf = "ErrStringOneOf"
// ErrStringIsEmail value is not a valid email
ErrStringIsEmail = "ErrStringIsEmail"
// ErrNumberRange when value is out of range
// Used in Number
ErrNumberRange = "ErrNumberRange"
// ErrNumberGT when value is not greater than
ErrNumberGT = "ErrNumberGT"
// ErrNumberGTE when value is not greater or equal than
ErrNumberGTE = "ErrNumberGTE"
// ErrNumberLT when value is not smaller than
ErrNumberLT = "ErrNumberLT"
// ErrNumberLTE when value is not smaller or equal than
ErrNumberLTE = "ErrNumberLTE"
)
var defaultErrMessage = map[string]string{
ErrValidation: "validation for '%v' failed: %v",
ErrRequired: "required",
ErrStringGT: "length is not greater than %v",
ErrStringGTE: "length is not greater or equal than %v",
ErrStringLT: "length is not smaller than %v",
ErrStringLTE: "length is not smaller or equal than %v",
ErrStringLength: "out of length(min:%v max:%v)",
ErrStringLen: "out of len(%v)",
ErrStringMatch: "does not match",
ErrStringOneOf: "value is not one of %v",
ErrStringIsEmail: "value is not a valid email",
ErrNumberRange: "out of range(min:%v max:%v)",
ErrNumberGT: "value is not greater than %v",
ErrNumberGTE: "value is not greater or equal than %v",
ErrNumberLT: "value is not smaller than %v",
ErrNumberLTE: "value is not smaller or equal than %v",
}