Skip to content

Getting panic when I'm trying to mock the ValidationErrors #980

@joselitofilho

Description

@joselitofilho
  • I have looked at the documentation here first?
  • I have looked at the examples provided that may showcase my question here?

Package version eg. v9, v10:

v10

Issue, Question or Enhancement:

I am trying to mock ValidationErrors and I've got a panic in the errors.go::Error() function in the cast of ve[i] to *fieldError.

So, to mock ValidationErrors we need to use the interface instead.

Code sample, to showcase or reproduce:

I created a mocked implementation for FieldError.

type MockFieldError struct {
	validator.FieldError

	ns string
}

func (fe *MockFieldError) Namespace() string {
	return fe.ns
}

func (fe *MockFieldError) Error() string {
	return "dummyError"
}

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