feat: add limit owner
This commit is contained in:
@@ -37,6 +37,10 @@ func (v *CategoryValidatorImpl) ValidateCreateCategoryRequest(req *contract.Crea
|
||||
return errors.New("description cannot exceed 1000 characters"), constants.MalformedFieldErrorCode
|
||||
}
|
||||
|
||||
if req.OwnerFeePercent != nil && (*req.OwnerFeePercent < 0 || *req.OwnerFeePercent > 100) {
|
||||
return errors.New("owner_fee_percent must be between 0 and 100"), constants.MalformedFieldErrorCode
|
||||
}
|
||||
|
||||
if req.BusinessType != nil && strings.TrimSpace(*req.BusinessType) != "" {
|
||||
validBusinessTypes := map[string]bool{
|
||||
"restaurant": true,
|
||||
@@ -59,7 +63,7 @@ func (v *CategoryValidatorImpl) ValidateUpdateCategoryRequest(req *contract.Upda
|
||||
}
|
||||
|
||||
// At least one field should be provided for update
|
||||
if req.Name == nil && req.Description == nil && req.BusinessType == nil && req.ParentID == nil && req.Metadata == nil {
|
||||
if req.Name == nil && req.Description == nil && req.BusinessType == nil && req.ParentID == nil && req.Metadata == nil && req.OwnerFeePercent == nil && req.Order == nil && req.OutletID == nil && !req.ClearParentID && !req.ClearOwnerFeePercent {
|
||||
return errors.New("at least one field must be provided for update"), constants.MissingFieldErrorCode
|
||||
}
|
||||
|
||||
@@ -76,6 +80,10 @@ func (v *CategoryValidatorImpl) ValidateUpdateCategoryRequest(req *contract.Upda
|
||||
return errors.New("description cannot exceed 1000 characters"), constants.MalformedFieldErrorCode
|
||||
}
|
||||
|
||||
if req.OwnerFeePercent != nil && (*req.OwnerFeePercent < 0 || *req.OwnerFeePercent > 100) {
|
||||
return errors.New("owner_fee_percent must be between 0 and 100"), constants.MalformedFieldErrorCode
|
||||
}
|
||||
|
||||
if req.BusinessType != nil && strings.TrimSpace(*req.BusinessType) != "" {
|
||||
validBusinessTypes := map[string]bool{
|
||||
"restaurant": true,
|
||||
|
||||
Reference in New Issue
Block a user