-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
50 lines (39 loc) · 811 Bytes
/
Copy pathexample_test.go
File metadata and controls
50 lines (39 loc) · 811 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package fielderrors_test
import (
"fmt"
"github.com/aatuh/api-toolkit/v4/fielderrors"
)
func ExampleFieldErrors() {
errs := fielderrors.FieldErrors{{
Field: "name",
Code: "required",
Message: "name is required",
}}
fmt.Println(errs.Error())
fmt.Println(errs.ToMap()["name"])
// Output:
// name is required
// name is required
}
func ExampleFieldError_Public() {
err := fielderrors.FieldError{
Field: "postal_code",
Code: "invalid",
Message: "postal code is invalid",
Public: true,
}
fmt.Println(err.Public)
// Output:
// true
}
func ExampleFieldErrors_AllPublic() {
errs := fielderrors.FieldErrors{{
Field: "postal_code",
Code: "invalid",
Message: "postal code is invalid",
Public: true,
}}
fmt.Println(errs.AllPublic())
// Output:
// true
}