Validate validates a value and returns nil if passed or the failure reason if does not.
(v interface{})
| 340 | // Validate validates a value and returns nil if passed or |
| 341 | // the failure reason if does not. |
| 342 | func (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 | |
| 367 | func newMinifier() *minify.M { |
| 368 | m := minify.New() |