MCPcopy
hub / github.com/gofiber/fiber / validateStruct

Method validateStruct

bind.go:194–219  ·  view source on GitHub ↗

Struct validation.

(out any)

Source from the content-addressed store, hash-verified

192
193// Struct validation.
194func (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.

Callers 14

CustomMethod · 0.95
HeaderMethod · 0.95
RespHeaderMethod · 0.95
CookieMethod · 0.95
QueryMethod · 0.95
JSONMethod · 0.95
CBORMethod · 0.95
XMLMethod · 0.95
FormMethod · 0.95
URIMethod · 0.95
MsgPackMethod · 0.95
BodyMethod · 0.95

Calls 2

AppMethod · 0.65
ValidateMethod · 0.65

Tested by 1