You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
curl -XPOST localhost:8080/api/auth/confirmation/send -d '{"user_id":4,"type":"sms"}'
{"errors":{"user_id":"must be either a string or byte slice"}}
It ask me to send a string.... But i need an int value. And sending a string causes struct error:
curl -XPOST localhost:8080/api/auth/confirmation/send -d '{"user_id":"asdsa","type":"sms"}'
{"error":"json: cannot unmarshal string into Go value of type int64"}
Any ideas? I'm new in go)
The text was updated successfully, but these errors were encountered:
Since you have already declared UserID to be an integer, you should remove the is.Int rule because it doesn't make sense to validate if an integer typed value is an int (that is always true, isn't it?)
FYI, all is.* rules only validate strings or byte arrays.
@qiangxue
That's right that we expect an integer for an integer when the struct declares so, but when we pass a string we expect the package to inform the user that the parameter should be an integer, not pass the validation and get a JSON unmarshal error!
So, there seems to be no way validating the type of a field would be integer for example by this package. Not?
and some main.go code
Sending integer user_id value
It ask me to send a string.... But i need an int value. And sending a string causes struct error:
Any ideas? I'm new in go)
The text was updated successfully, but these errors were encountered: