Answer the question
In order to leave comments, you need to log in
Is it possible to pass the index of a structure as a pointer to a function?
Something like this:
type Registrat struct {
Username string `form:"username"`
Phone string `form:"phone"`
Email string `form:"email"`
Password string `form:"password"`
Title string `form:"title"`
Age uint8 `form:"age"`
Height uint8 `form:"height"`
Weight uint8 `form:"weight"`
Body uint8 `form:"body"`
}
func registration(data Registrat) (*Registrat, error) {
if !isPasswordValid(&data.Password) {
return &data, errors.New("incorrect password")
}
return &data, nil
}
func isPasswordValid(password *Registrat.Password) bool {
if len(password) < 8 || len(password) > 128 {
return false
}
}
Answer the question
In order to leave comments, you need to log in
func isPasswordValid(password string) bool {
if len(password) < 8 || len(password) > 128 {
return false
}
return true
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question