Skip to content

Pass the whole field to StructValidatorFunc instead of breaking it #16

@vitorestevam

Description

@vitorestevam

I was doing some tests relate to issue #14 not having field's information were causing me some trouble. Then i just found out the function parameters were taking parts of the field struct.

I think breaking a struct in many pieces is a not very good pratice and for every new verification of the field we want to do inside the function a new parameter needs to be created.

Better error messages is a example of this. I want to use the Field name in the message and a new parameter would have to be created.

Here is my suggestion

turn
type StructValidatorFunc func(v reflect.Value, typ reflect.Type, param string) error

into
type StructValidatorFunc func(field field, param string) error

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions