I want to add support for pointers. But there are a lot of side effects from adding a feature like this. Mostly related to if Zog creates values using reflection when the pointer is nil
Why do we need pointers??
Imagine you have a user struct
type User struct {
Name string
Age int
}
var userSchema = z.Struct(z.Schema{
"name": z.String().Required(),
"age": z.Int(),
})
There is no way, currently, in zog to differentiate between user.age = 0 (meaning new born baby) and someone that has not set their age. For that we can do a workaround by adding another field to indicate if age is set or we can have a pointer.
So what is the problem???
If we support pointers, who creates the values when the pointer is nil? Does zog do it? What happens if you set a pointer to be required (since there is a kinda conflict of logic there).
Currently we would need the data structure to actually validate it. So if you have a very large data structure Zog might create a lot of memory unnecesarily
I want to add support for pointers. But there are a lot of side effects from adding a feature like this. Mostly related to if Zog creates values using reflection when the pointer is
nil
Why do we need pointers?? Imagine you have a user struct
There is no way, currently, in zog to differentiate between user.age = 0 (meaning new born baby) and someone that has not set their age. For that we can do a workaround by adding another field to indicate if age is set or we can have a pointer.
So what is the problem??? If we support pointers, who creates the values when the pointer is nil? Does zog do it? What happens if you set a pointer to be required (since there is a kinda conflict of logic there).
Currently we would need the data structure to actually validate it. So if you have a very large data structure Zog might create a lot of memory unnecesarily