ValidateFields checks the field values on Client with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.
(paths ...string)
| 36 | // the proto definition for this message. If any rules are violated, an error |
| 37 | // is returned. |
| 38 | func (m *Client) ValidateFields(paths ...string) error { |
| 39 | if m == nil { |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | if len(paths) == 0 { |
| 44 | paths = ClientFieldPathsNested |
| 45 | } |
| 46 | |
| 47 | for name, subs := range _processPaths(append(paths[:0:0], paths...)) { |
| 48 | _ = subs |
| 49 | switch name { |
| 50 | case "ids": |
| 51 | |
| 52 | if m.GetIds() == nil { |
| 53 | return ClientValidationError{ |
| 54 | field: "ids", |
| 55 | reason: "value is required", |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | if v, ok := interface{}(m.GetIds()).(interface{ ValidateFields(...string) error }); ok { |
| 60 | if err := v.ValidateFields(subs...); err != nil { |
| 61 | return ClientValidationError{ |
| 62 | field: "ids", |
| 63 | reason: "embedded message failed validation", |
| 64 | cause: err, |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | case "created_at": |
| 70 | |
| 71 | if v, ok := interface{}(m.GetCreatedAt()).(interface{ ValidateFields(...string) error }); ok { |
| 72 | if err := v.ValidateFields(subs...); err != nil { |
| 73 | return ClientValidationError{ |
| 74 | field: "created_at", |
| 75 | reason: "embedded message failed validation", |
| 76 | cause: err, |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | case "updated_at": |
| 82 | |
| 83 | if v, ok := interface{}(m.GetUpdatedAt()).(interface{ ValidateFields(...string) error }); ok { |
| 84 | if err := v.ValidateFields(subs...); err != nil { |
| 85 | return ClientValidationError{ |
| 86 | field: "updated_at", |
| 87 | reason: "embedded message failed validation", |
| 88 | cause: err, |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | case "deleted_at": |
| 94 | |
| 95 | if v, ok := interface{}(m.GetDeletedAt()).(interface{ ValidateFields(...string) error }); ok { |
no test coverage detected