Struct validation.
(out any)
| 192 | |
| 193 | // Struct validation. |
| 194 | func (b *Bind) validateStruct(out any) error { |
| 195 | if b.shouldSkipValidation { |
| 196 | return nil |
| 197 | } |
| 198 | |
| 199 | validator := b.ctx.App().config.StructValidator |
| 200 | if validator == nil { |
| 201 | return nil |
| 202 | } |
| 203 | |
| 204 | t := reflect.TypeOf(out) |
| 205 | if t == nil { |
| 206 | return nil |
| 207 | } |
| 208 | |
| 209 | // Unwrap pointers (e.g. *T, **T) to inspect the underlying destination type. |
| 210 | for t.Kind() == reflect.Pointer { |
| 211 | t = t.Elem() |
| 212 | } |
| 213 | |
| 214 | if t.Kind() != reflect.Struct { |
| 215 | return nil |
| 216 | } |
| 217 | |
| 218 | return validator.Validate(out) |
| 219 | } |
| 220 | |
| 221 | // Custom To use custom binders, you have to use this method. |
| 222 | // You can register them from RegisterCustomBinder method of Fiber instance. |