Skip to content

[Bug]: validateFn does not propagage errors upwards #1575

@gabyx

Description

@gabyx

What happened?

when using

package main

import (
	"errors"
	"fmt"

	val "github.com/go-playground/validator/v10"
)

type S struct {
	A string `validate:"validateFn"`
}

func (s *S) Validate() error {
	return errors.New("huha")
}

func main() {
	var s S
	e := val.New().Struct(&s)

	fmt.Printf("%v", e)
}

on a struct field A, the Validate() error function is called but the error returned from that function is never accesible in the result e.

Only an error:

Key: 'A' Error:Field validation for 'A' failed on the 'validateFn' tag"

is printed.

Also casting to validation.ValidationError does not help.

Version

10.30

Example Code

see above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions