Enhance Customer Module with Validation and Username Handling
- Introduced a new ValidationService for customer operations to ensure valid username formats. - Updated customer service and handler to utilize the new validation service, enhancing input validation during registration and updates. - Modified CreateCustomerForm and UpdateCustomerForm to enforce username validation rules. - Adjusted repository indexing to improve search efficiency by refining the text index for customer data. - Ensured consistent handling of usernames across the customer module, improving overall data integrity and user experience.
This commit is contained in:
@@ -13,7 +13,7 @@ type CreateCustomerForm struct {
|
||||
Type string `json:"type" valid:"required,in(individual|company|government)" example:"individual"`
|
||||
Role string `json:"role" valid:"required,in(admin|analyst)" example:"analyst"`
|
||||
Companies []string `json:"companies,omitempty" valid:"optional"`
|
||||
Username string `json:"username" valid:"required,alphanum,length(3|30)" example:"user"`
|
||||
Username string `json:"username" valid:"required,username,length(3|30)" example:"user"`
|
||||
Email string `json:"email" valid:"required,email" example:"user@opplens.com"`
|
||||
Password string `json:"password" valid:"required,length(8|128)" example:"User!1234"`
|
||||
Phone *string `json:"phone,omitempty" valid:"optional,length(10|20)" example:"+1234567890"`
|
||||
@@ -25,7 +25,7 @@ type UpdateCustomerForm struct {
|
||||
Type string `json:"type" valid:"required,in(individual|company|government)" example:"individual"`
|
||||
Role string `json:"role" valid:"required,in(admin|analyst)" example:"analyst"`
|
||||
Companies []string `json:"companies,omitempty" valid:"optional"`
|
||||
Username string `json:"username" valid:"required,alphanum,length(3|30)" example:"user"`
|
||||
Username string `json:"username" valid:"required,username,length(3|30)" example:"user"`
|
||||
Email string `json:"email" valid:"required,email" example:"user@opplens.com"`
|
||||
Phone *string `json:"phone,omitempty" valid:"optional,length(10|20)" example:"+1234567890"`
|
||||
}
|
||||
@@ -132,7 +132,7 @@ type ChangePasswordForm struct {
|
||||
|
||||
type UpdateProfileForm struct {
|
||||
FullName *string `json:"full_name,omitempty" valid:"optional,length(2|100)"`
|
||||
Username *string `json:"username,omitempty" valid:"optional,alphanum,length(3|30)"`
|
||||
Username *string `json:"username,omitempty" valid:"optional,username,length(3|30)"`
|
||||
Phone *string `json:"phone,omitempty" valid:"optional,length(10|20)"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user