Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add validate to bast #1

Open
axfor opened this issue Dec 15, 2019 · 1 comment
Open

add validate to bast #1

axfor opened this issue Dec 15, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@axfor
Copy link
Owner

axfor commented Dec 15, 2019

add validate to bast

support struct

josn etc...

such as:

    type vv struct {
		A string  `json:"a" v:"required|min:1"`
		B *string `json:"b" v:"required|min:1"`
	}

	g := "a"
	v := vv{A: "a", B: &g}
	v2 := []vv{{A: "b", B: &g}}
	v3 := map[string]vv{"c": vv{A: "c", B: &g}}

	vr := Validator{}

	err := vr.Struct(v)
	if err != nil {
		t.Error(err)
	}

	err = vr.Struct(v2)
	if err != nil {
		t.Error(err)
	}

	err = vr.Struct(v3)
	if err != nil {
		t.Error(err)
	}

support url.Values

*http.Request etc...

such as:

    v4 := url.Values{
        "d": {
            "15",
        },
        "e": {
            "eeeee",
        },
        "f": {
            "ff",
        },
    }
    vr := Validator{}
    err := vr.Request(v4, "d@required|int|min:12|max:16", "e@required|min:5")
    if err != nil {
        t.Error(err)
    }
@axfor axfor added enhancement New feature or request good first issue Good for newcomers labels Dec 15, 2019
@axfor axfor self-assigned this Dec 15, 2019
@axfor
Copy link
Owner Author

axfor commented Feb 6, 2020

Support for the validator

note:will continue to add new validator

  • date
  • email
  • int
  • ip
  • match
  • max
  • min
  • required
  • sometimes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant