Godeps/_workspace/src/gopkg.in/bluesuncorp/validator.v5/validator.go
func (e *FieldError) Flatten() map[string]*FieldError {

	errs := map[string]*FieldError{}

	if e.IsPlaceholderErr {

		if e.IsSliceOrArray {
			for key, err := range e.SliceOrArrayErrs {

				fe, ok := err.(*FieldError)

				if ok {

					if flat := fe.Flatten(); flat != nil && len(flat) > 0 {
						for k, v := range flat {
							if fe.IsPlaceholderErr {
								errs[fmt.Sprintf("[%#v]%s", key, k)] = v
							} else {
								errs[fmt.Sprintf("[%#v]", key)] = v
							}

						}
					}
				} else {

					se := err.(*StructErrors)

					if flat := se.Flatten(); flat != nil && len(flat) > 0 {
						for k, v := range flat {
							errs[fmt.Sprintf("[%#v].%s.%s", key, se.Struct, k)] = v
						}
					}
				}
			}
		}

		if e.IsMap {
			for key, err := range e.MapErrs {

				fe, ok := err.(*FieldError)

				if ok {

					if flat := fe.Flatten(); flat != nil && len(flat) > 0 {
						for k, v := range flat {
							if fe.IsPlaceholderErr {
								errs[fmt.Sprintf("[%#v]%s", key, k)] = v
							} else {
								errs[fmt.Sprintf("[%#v]", key)] = v
							}
						}
					}
				} else {

					se := err.(*StructErrors)

					if flat := se.Flatten(); flat != nil && len(flat) > 0 {
						for k, v := range flat {
							errs[fmt.Sprintf("[%#v].%s.%s", key, se.Struct, k)] = v
						}
					}
				}
			}
		}

		return errs
	}

	errs[e.Field] = e

	return errs
}
func (e *FieldError) Flatten() map[string]*FieldError {

	errs := map[string]*FieldError{}

	if e.IsPlaceholderErr {

		if e.IsSliceOrArray {
			for key, err := range e.SliceOrArrayErrs {

				fe, ok := err.(*FieldError)

				if ok {

					if flat := fe.Flatten(); flat != nil && len(flat) > 0 {
						for k, v := range flat {
							if fe.IsPlaceholderErr {
								errs[fmt.Sprintf("[%#v]%s", key, k)] = v
							} else {
								errs[fmt.Sprintf("[%#v]", key)] = v
							}

						}
					}
				} else {

					se := err.(*StructErrors)

					if flat := se.Flatten(); flat != nil && len(flat) > 0 {
						for k, v := range flat {
							errs[fmt.Sprintf("[%#v].%s.%s", key, se.Struct, k)] = v
						}
					}
				}
			}
		}

		if e.IsMap {
			for key, err := range e.MapErrs {

				fe, ok := err.(*FieldError)

				if ok {

					if flat := fe.Flatten(); flat != nil && len(flat) > 0 {
						for k, v := range flat {
							if fe.IsPlaceholderErr {
								errs[fmt.Sprintf("[%#v]%s", key, k)] = v
							} else {
								errs[fmt.Sprintf("[%#v]", key)] = v
							}
						}
					}
				} else {

					se := err.(*StructErrors)

					if flat := se.Flatten(); flat != nil && len(flat) > 0 {
						for k, v := range flat {
							errs[fmt.Sprintf("[%#v].%s.%s", key, se.Struct, k)] = v
						}
					}
				}
			}
		}

		return errs
	}

	errs[e.Field] = e

	return errs
}
func ( e * FieldError ) Flatten ( ) map [ string ] * FieldError { errs := map [ string ] * FieldError { } if e . IsPlaceholderErr { if e . IsSliceOrArray { for key , err := range e . SliceOrArrayErrs { fe , ok := err . ( * FieldError ) if ok { if flat := fe . Flatten ( ) ; flat != nil && len ( flat ) > 0 { for k , v := range flat { if fe . IsPlaceholderErr { errs [ fmt . Sprintf ( " " , key , k ) ] = v } else { errs [ fmt . Sprintf ( " " , key ) ] = v } } } } else { se := err . ( * StructErrors ) if flat := se . Flatten ( ) ; flat != nil && len ( flat ) > 0 { for k , v := range flat { errs [ fmt . Sprintf ( " " , key , se . Struct , k ) ] = v } } } } } if e . IsMap { for key , err := range e . MapErrs { fe , ok := err . ( * FieldError ) if ok { if flat := fe . Flatten ( ) ; flat != nil && len ( flat ) > 0 { for k , v := range flat { if fe . IsPlaceholderErr { errs [ fmt . Sprintf ( " " , key , k ) ] = v } else { errs [ fmt . Sprintf ( " " , key ) ] = v } } } } else { se := err . ( * StructErrors ) if flat := se . Flatten ( ) ; flat != nil && len ( flat ) > 0 { for k , v := range flat { errs [ fmt . Sprintf ( " " , key , se . Struct , k ) ] = v } } } } } return errs } errs [ e . Field ] = e return errs }
// Flatten flattens the FieldError hierarchical structure into a flat namespace style field name
// for those that want/need it.
// This is now needed because of the new dive functionality
Flatten flattens the FieldError hierarchical structure into a flat namespace style field name for those that want / need it . This is now needed because of the new dive functionality