Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Dean Karn
@deankarn
The validation I mention, that should work for your case
Ryan King
@ryanking
how do i get FieldError Namespace() to take into account json tag names? some of the docs make it sound like that should be happening, but it doesn't seem to be working for me
Dean Karn
@deankarn
Have you registered a tagNameFunc? That's OST likely why it wouldn't
*most likely
Ryan King
@ryanking
@joeybloggs oh I thought it would pick up names from the json tags already?
Dean Karn
@deankarn
it used to in an older version, but defining your own allows for much more flexible parsing of names, even from tags other than JSON
Ryan King
@ryanking
ah ok that makes sense
emurmotol
@emurmotol
how to validate big ints?
Value *big.Int json:"value" binding:"required,min=1000000000000000" // does not work
Franklin Harding
@fharding1
Hello! I just created this PR to add excludesfield and containsfield baked-in validators: go-playground/validator#424.
Pomke
@pomke
Hiya, sorry if this is a bit of a newbie question, I have a struct:
type LoginProvider struct {
Email string json:"email"
Phone string json:"phone"
Password string json:"password"
}
I want to validate XOR email and Phone
ie: you must provide either Email or Phone, but not both
Dean Karn
@deankarn
@pomke Once getting that specific I recommend either creating your own custom validation or creations a struct level validation.
Pomke
@pomke
Ok thank you ^_^
Devi
@asldevi
Hi, how can one inject something from application in the custom validation functions ?
Dean Karn
@deankarn
@asldevi You can Register a validation function that accepts context.Context and then use one of the validation functions that accept it eg. validate.StructCtx, but that's if it's dynamic, if looking to embed static logic from the application see here for an example go-playground/validator#462
Devi
@asldevi
thanks @deankarn
Emir Ribić
@ribice
Is this still active
:D
Dean Karn
@deankarn
yes
PhamDuykhang
@PhamDuykhang
Which tag can use for validate a string, i want to validate wich to string "times" and "Money"
Dean Karn
@deankarn

Documentation can be found here with all tags https://godoc.org/gopkg.in/go-playground/validator.v9

At present there is no built in "Money" nor "times" validator due to different locales having to validate differently, but you can create your own validations :)

Nonny Psk
@ivybridge-3c33
I would like to check file upload is matching mime types or file extension, please help
example use :
type Photo struct { 
   Photo string `validate:"mimes=jpeg|bmp|png"`
}