package generated import ( passwordvalidator "github.com/wagslane/go-password-validator" "net/mail" "strings" ) func (input CustomerCreateInput) ValidatePassword(minPasswordEntropy float64) *CustomerUserError { var code CustomerErrorCode if strings.HasPrefix(input.Password, " ") || strings.HasSuffix(input.Password, " ") { code = CustomerErrorCodePasswordStartsOrEndsWithWhitespace return &CustomerUserError{ Code: &code, Field: []string{"password"}, Message: "password must not start or end with whitespaces", } } if err := passwordvalidator.Validate(input.Password, minPasswordEntropy); err != nil { code = CustomerErrorCodeBlank return &CustomerUserError{ Code: &code, Field: []string{"password"}, Message: err.Error(), } } return nil } func (input CustomerCreateInput) ValidateEmail() *CustomerUserError { addr, err := mail.ParseAddress(input.Email) if err != nil { code := CustomerErrorCodeInvalid return &CustomerUserError{ Code: &code, Field: []string{"email"}, Message: err.Error(), } } input.Email = addr.Address return nil }