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

[BUG] validation of binding is not effective #2303

Closed
aveyuan opened this issue Dec 7, 2023 · 0 comments
Closed

[BUG] validation of binding is not effective #2303

aveyuan opened this issue Dec 7, 2023 · 0 comments
Assignees

Comments

@aveyuan
Copy link
Contributor

aveyuan commented Dec 7, 2023

Demo

package main

import "github.com/kataras/iris/v12"

type Person struct {
    Name    string `url:"name,required"`
    Address string `url:"address"`
}

func main() {
    app := iris.Default()
    app.Any("/", index)
    app.Listen(":8080")
}

func index(ctx iris.Context) {
    var person Person
    if err := ctx.ReadQuery(&person); err!=nil {
        ctx.StopWithError(iris.StatusBadRequest, err)
        return
    }

    ctx.Application().Logger().Infof("Person: %#+v", person)
    ctx.WriteString("Success")
}

The reuqest url name is empty. but it tag is required. use ctx.ReadQuery(&person) not return err. validation is not effective ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants