Skip to content

Regex support #1239

Closed
Closed
@Vyacheslav1557

Description

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

Enhancement:

Why dont you add a new regexp tag like so

type Country struct {
	Name   string `validate:"required" regexp:"^.{1,100}$"`
	Alpha2 string `validate:"required" regexp:"^[a-zA-Z]{2}$"`
	Alpha3 string `validate:"required" regexp:"^[a-zA-Z]{3}$"`
	Region string `regexp:"^Europe$|^Africa$|^Americas$|^Oceania$|^Asia$"`
}

I know that it won’t be possible to add support for regexp inside the validate tag and maybe this is against the design, but regexp is also a basic tool that everyone needs.

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