Code Monkey home page Code Monkey logo

Comments (4)

veeral-patel avatar veeral-patel commented on July 17, 2024

@thedevsaddam I found a similar issue: #9

Where you linked to this page: https://github.com/thedevsaddam/govalidator/blob/master/doc/SIMPLE_STRUCT_VALIDATION.md

However, I didn't see anything on this page that would solve my problem! Perhaps it is out of date?

Thanks again!

from govalidator.

thedevsaddam avatar thedevsaddam commented on July 17, 2024

Probably you can use min:numeric rule

from govalidator.

veeral-patel avatar veeral-patel commented on July 17, 2024

@thedevsaddam Thanks for your reply! Sorry for closing/reopening this ticket on accident.

Here are my validation rules:

	validator := govalidator.New(govalidator.Options{
		Data: &requestBody,
		Rules: govalidator.MapData{
			"title":      []string{"required", "max:255"},
			"x":          []string{"required", "min:0", "max:11"},
			"y":          []string{"required", "min:0"},
			"w":          []string{"required", "min:1", "max:12"},
			"h":          []string{"required", "min:1"},
			"panel_type": []string{"required", "max:255"},
		},
	})

And here's the errors I get from govalidator:

Screen Shot 2019-12-18 at 10 16 13 AM

Note that I provided a value for x and y (0) but govalidator tells me x and y are required.

If I set x to any integer >= 1, then I don't get this "field is required" error in the two fields. I think what's happening is that required requires integers to not be 0 (as per the README).

In my example, how can I require the x field but also allow it to be 0?

from govalidator.

thedevsaddam avatar thedevsaddam commented on July 17, 2024

Can you please share the data struct that you are using

from govalidator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.