iris icon indicating copy to clipboard operation
iris copied to clipboard

[BUG] Unable to attach Validator on iris Application

Open dpkahuja-jg opened this issue 3 years ago • 3 comments

Describe the bug A clear and concise description of what the bug is. Unable to attach validator on iris Application instance.

app.Validator undefined (type *iris.Application has no field or method Validator)

To Reproduce Steps to reproduce the behavior: example here https://github.com/kataras/iris/blob/master/_examples/request-body/read-json-struct-validation/main.go

Expected behavior A clear and concise description of what you expected to happen. Validator should attach Screenshots image

Desktop (please complete the following information):

  • OS: [e.g. ubuntu, windows]

iris.Version

  • e.g. v12.2.0-alpha or master

Please make sure the bug is reproducible over the master branch:

$ cd PROJECT
$ go get -u github.com/kataras/iris/v12@master
$ go run .

Additional context Add any other context about the problem here. Even if i use readJSON to read the body with struct tags described in example, no error is thrown. validator is expected to run manually. Am i missing anything?

dpkahuja-jg avatar Apr 14 '21 11:04 dpkahuja-jg

Realised that this feature is not yet released. Anyways thanks for making this package. i am starting using it for a new service. so alpha code is not yet merged in master? i am using "github.com/kataras/iris/v12"

dpkahuja-jg avatar Apr 15 '21 05:04 dpkahuja-jg

image

try go get -u github.com/kataras/iris/v12@master

tuhao1020 avatar Apr 21 '21 15:04 tuhao1020

v12.2.0-alpha iris.go line:339

err := app.Validator.Struct(v)
if err != nil {
	if !strings.HasPrefix(err.Error(), "validator: ") {
		return err
	}
}

while validate failed, but !strings.HasPrefix(err.Error(), "validator: ") omit。

jyno12 avatar Jun 08 '21 03:06 jyno12