Skip to content

Avoid the use of types package as a proxy do stdlib #51

@alexgarzao

Description

@alexgarzao

The package types has some important definitions like the type ValidationError and the func IsValidEmail.

However, this package as been used as a bag to avoid add imports during the generation of the validator file.

After this issue completed, types no more be used as a proxy to stdlib.

For a slice of string, instead of generate this:

if !(types.SlicesContains(obj.TypesIn, "a") || types.SlicesContains(obj.TypesIn, "b") || types.SlicesContains(obj.TypesIn, "c")) {
	errs = append(errs, types.NewValidationError("TypesIn elements must be one of 'a' 'b' 'c'"))
}

will be generated something like this:

import "slices"

if !(slices.SlicesContains(obj.TypesIn, "a") || slices.SlicesContains(obj.TypesIn, "b") || slices.SlicesContains(obj.TypesIn, "c")) {
	errs = append(errs, types.NewValidationError("TypesIn elements must be one of 'a' 'b' 'c'"))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions