MCPcopy Create free account
hub / github.com/kataras/iris / Validate

Method Validate

iris.go:342–365  ·  view source on GitHub ↗

Validate validates a value and returns nil if passed or the failure reason if does not.

(v interface{})

Source from the content-addressed store, hash-verified

340// Validate validates a value and returns nil if passed or
341// the failure reason if does not.
342func (app *Application) Validate(v interface{}) error {
343 if app.Validator == nil {
344 return nil
345 }
346
347 // val := reflect.ValueOf(v)
348 // if val.Kind() == reflect.Ptr && !val.IsNil() {
349 // val = val.Elem()
350 // }
351
352 // if val.Kind() == reflect.Struct && val.Type() != timeType {
353 // return app.Validator.Struct(v)
354 // }
355
356 // no need to check the kind, underline lib does it but in the future this may change (look above).
357 err := app.Validator.Struct(v)
358 if err != nil {
359 if !strings.HasPrefix(err.Error(), "validator: ") {
360 return err
361 }
362 }
363
364 return nil
365}
366
367func newMinifier() *minify.M {
368 m := minify.New()

Callers

nothing calls this directly

Calls 2

StructMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected