Comments (4)
@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.
Probably you can use min:numeric
rule
from govalidator.
@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:
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.
Can you please share the data struct that you are using
from govalidator.
Related Issues (20)
- How can I verify the uint64 type? I canβt verify it with numeric. HOT 1
- decimal.Decimal field can not be parsed correctly.
- Reject superfluous properties
- How to use it on GoFiber? HOT 3
- confirm password validation HOT 1
- numeric_between not considering float value in range.
- How to validate with nested struct ? HOT 1
- Support for Validating multiple files.
- go get error,constant -9223372036854775808 overflows int
- Regex for blank space is not working
- Is there any way to check if a custom rule already exists or not? HOT 2
- How to validate slice of struct ?
- how to validate struct in struct? HOT 5
- Invalid Read on closed Body
- Can I use this with Echo? HOT 1
- Nested validation doesn't working HOT 1
- Unmarshalling failure happens before validation failure HOT 1
- Why not custom message with rule between when value is float32 and float64?
- Map validated query\form to a struct. HOT 2
- Latitude & Longitude doesn't validate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from govalidator.