Validate the inputs. The type should be the Go struct with validation field tags and the value should be e.g. JSON loaded into an `any`. A list of errors is returned if validation failed, otherwise `nil`. type MyExample struct { Name string `json:"name" maxLength:"5"` Age int `json:"age" minim
(typ reflect.Type, value any)
| 889 | // fmt.Println("Validation error", errs) |
| 890 | // } |
| 891 | func (v *ModelValidator) Validate(typ reflect.Type, value any) []error { |
| 892 | v.pb.Reset() |
| 893 | v.result.Reset() |
| 894 | |
| 895 | s := v.registry.Schema(typ, true, typ.Name()) |
| 896 | |
| 897 | Validate(v.registry, s, v.pb, ModeReadFromServer, value, v.result) |
| 898 | |
| 899 | if len(v.result.Errors) > 0 { |
| 900 | return v.result.Errors |
| 901 | } |
| 902 | return nil |
| 903 | } |
| 904 | |
| 905 | // The following is borrowed from the Google UUID package: |
| 906 | // https://github.com/google/uuid/blob/v1.6.0/uuid.go |