Skip to content

use error struct over map[string][]error #9

Description

@bodokaiser

I see this is controversy but I give it a try:

type ValidationError struct {
    Errors map[string][]error
}

// Returns first error.
func (err ValidationError) Error() {
    for k, errs := range err.Errors {
        return k + " value had " + errs[0].Error()
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions