add dukcapil
This commit is contained in:
@@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"eslogad-be/internal/constants"
|
||||
"eslogad-be/internal/contract"
|
||||
"go-backend-template/internal/constants"
|
||||
"go-backend-template/internal/contract"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
@@ -37,10 +37,6 @@ func (v *UserValidatorImpl) ValidateCreateUserRequest(req *contract.CreateUserRe
|
||||
return errors.New("password must be at least 6 characters"), constants.MalformedFieldErrorCode
|
||||
}
|
||||
|
||||
if req.RoleID == nil {
|
||||
return errors.New("role is required"), constants.MissingFieldErrorCode
|
||||
}
|
||||
|
||||
return nil, ""
|
||||
}
|
||||
|
||||
@@ -49,7 +45,7 @@ func (v *UserValidatorImpl) ValidateUpdateUserRequest(req *contract.UpdateUserRe
|
||||
return errors.New("request body is required"), constants.MissingFieldErrorCode
|
||||
}
|
||||
|
||||
if req.Email == nil && req.Role == nil && req.IsActive == nil {
|
||||
if req.Email == nil && req.IsActive == nil {
|
||||
return errors.New("at least one field must be provided for update"), constants.MissingFieldErrorCode
|
||||
}
|
||||
|
||||
@@ -62,15 +58,6 @@ func (v *UserValidatorImpl) ValidateUpdateUserRequest(req *contract.UpdateUserRe
|
||||
}
|
||||
}
|
||||
|
||||
// if req.Role != nil {
|
||||
// if strings.TrimSpace(*req.Role) == "" {
|
||||
// return errors.New("role cannot be empty"), constants.MalformedFieldErrorCode
|
||||
// }
|
||||
// // if !isValidUserRole(*req.Role) {
|
||||
// // return errors.New("invalid user role"), constants.MalformedFieldErrorCode
|
||||
// // }
|
||||
// }
|
||||
|
||||
return nil, ""
|
||||
}
|
||||
|
||||
@@ -91,10 +78,6 @@ func (v *UserValidatorImpl) ValidateListUsersRequest(req *contract.ListUsersRequ
|
||||
return errors.New("limit cannot exceed 100"), constants.MalformedFieldErrorCode
|
||||
}
|
||||
|
||||
if req.Role != nil && !isValidUserRole(*req.Role) {
|
||||
return errors.New("invalid user role filter"), constants.MalformedFieldErrorCode
|
||||
}
|
||||
|
||||
return nil, ""
|
||||
}
|
||||
|
||||
@@ -129,21 +112,3 @@ func (v *UserValidatorImpl) ValidateUserID(userID uuid.UUID) (error, string) {
|
||||
|
||||
return nil, ""
|
||||
}
|
||||
|
||||
func isValidUserRole(role string) bool {
|
||||
validRoles := map[string]bool{
|
||||
string(constants.RoleAdmin): true,
|
||||
string(constants.RoleManager): true,
|
||||
string(constants.RoleCashier): true,
|
||||
string(constants.RoleWaiter): true,
|
||||
}
|
||||
return validRoles[role]
|
||||
}
|
||||
|
||||
func (v *UserValidatorImpl) ValidateUpdateUserOutletRequest(req *contract.UpdateUserOutletRequest) (error, string) {
|
||||
if req.OutletID == uuid.Nil {
|
||||
return errors.New("outlet_id is required"), constants.MissingFieldErrorCode
|
||||
}
|
||||
|
||||
return nil, ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user