Here is my validation structure:
type PostEmail struct {
Username string `json:"username" validate:"required"`
Email string `json:"email" validate:"required"`
IsRefreshEmail *bool `json:"isRefreshEmail" validate:"required"`
}
I'm pointing the value of IsRefreshEmail with *bool. If I remove the pointer and I try to call my API without it, the API will throw a bad syntax error.
That will happen only if the boolean value will be false. If it's true even if you remove the pointer the API will respond correctly.
Why is this happening? It's normal? I can't understand it and i don't even know if I'm doing it wrong with the pointer. What I surely know is that if I remove the * from bool and I insert false as value in postman for the field isRefreshEmail the API will throw an exception.
Someone can explain please? Thank you.