-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrresp.go
More file actions
27 lines (26 loc) · 789 Bytes
/
errresp.go
File metadata and controls
27 lines (26 loc) · 789 Bytes
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
package validator
// ErrorResponse interface
type ErrorResponse interface {
// AddError add new error
AddError(field, tag, message string)
// HasError check if response has error
HasError() bool
// Failed check if field has error
// @example:
// resp.Failed("firstname")
Failed(field string) bool
// FailedOn check if field has special error
// @example:
// resp.FailedOn("firstname", "required")
FailedOn(field, err string) bool
// Errors get errors list
Errors() map[string]map[string]string
// String convert to string
String() string
// Messages get error messages only without error key
Messages() map[string][]string
// Rules get error rules only without error message
Rules() map[string][]string
// MarshalJSON convert to json
MarshalJSON() ([]byte, error)
}