binding.go
func Validate(obj interface{}) martini.Handler {
	return func(context martini.Context, req *http.Request) {
		var errors Errors

		v := reflect.ValueOf(obj)
		k := v.Kind()

		if k == reflect.Interface || k == reflect.Ptr {

			v = v.Elem()
			k = v.Kind()
		}

		if k == reflect.Slice || k == reflect.Array {

			for i := 0; i < v.Len(); i++ {

				e := v.Index(i).Interface()
				errors = validateStruct(errors, e)

				if validator, ok := e.(Validator); ok {
					errors = validator.Validate(errors, req)
				}
			}
		} else {

			errors = validateStruct(errors, obj)

			if validator, ok := obj.(Validator); ok {
				errors = validator.Validate(errors, req)
			}
		}
		context.Map(errors)
	}
}
func Validate(obj interface{}) martini.Handler {
	return func(context martini.Context, req *http.Request) {
		var errors Errors

		v := reflect.ValueOf(obj)
		k := v.Kind()

		if k == reflect.Interface || k == reflect.Ptr {

			v = v.Elem()
			k = v.Kind()
		}

		if k == reflect.Slice || k == reflect.Array {

			for i := 0; i < v.Len(); i++ {

				e := v.Index(i).Interface()
				errors = validateStruct(errors, e)

				if validator, ok := e.(Validator); ok {
					errors = validator.Validate(errors, req)
				}
			}
		} else {

			errors = validateStruct(errors, obj)

			if validator, ok := obj.(Validator); ok {
				errors = validator.Validate(errors, req)
			}
		}
		context.Map(errors)
	}
}
func Validate ( obj interface { } ) martini . Handler { return func ( context martini . Context , req * http . Request ) { var errors Errors v := reflect . ValueOf ( obj ) k := v . Kind ( ) if k == reflect . Interface || k == reflect . Ptr { v = v . Elem ( ) k = v . Kind ( ) } if k == reflect . Slice || k == reflect . Array { for i := 0 ; i < v . Len ( ) ; i ++ { e := v . Index ( i ) . Interface ( ) errors = validateStruct ( errors , e ) if validator , ok := e . ( Validator ) ; ok { errors = validator . Validate ( errors , req ) } } } else { errors = validateStruct ( errors , obj ) if validator , ok := obj . ( Validator ) ; ok { errors = validator . Validate ( errors , req ) } } context . Map ( errors ) } }
// Validate is middleware to enforce required fields. If the struct
// passed in implements Validator, then the user-defined Validate method
// is executed, and its errors are mapped to the context. This middleware
// performs no error handling: it merely detects errors and maps them.
Validate is middleware to enforce required fields . If the struct passed in implements Validator then the user - defined Validate method is executed and its errors are mapped to the context . This middleware performs no error handling : it merely detects errors and maps them .