diff --git a/pkg/validator/iccid.go b/pkg/validator/iccid.go index bf330ba..6d9bd8d 100644 --- a/pkg/validator/iccid.go +++ b/pkg/validator/iccid.go @@ -2,8 +2,6 @@ package validator import ( "regexp" - - "github.com/break/junhong_cmp_fiber/pkg/constants" ) var iccidRegex = regexp.MustCompile(`^[0-9A-Za-z]+$`) @@ -15,7 +13,6 @@ type ICCIDValidationResult struct { // ValidateICCID 根据运营商类型验证 ICCID 格式 // carrierType: 运营商类型编码 (CMCC/CUCC/CTCC/CBN) -// 电信(CTCC) ICCID 长度为 19 位,其他运营商为 20 位 func ValidateICCID(iccid string, carrierType string) ICCIDValidationResult { if iccid == "" { return ICCIDValidationResult{Valid: false, Message: "ICCID 不能为空"} @@ -25,26 +22,10 @@ func ValidateICCID(iccid string, carrierType string) ICCIDValidationResult { return ICCIDValidationResult{Valid: false, Message: "ICCID 只能包含字母和数字"} } - length := len(iccid) - expectedLength := getExpectedICCIDLength(carrierType) - - if length != expectedLength { - if carrierType == constants.CarrierCodeCTCC { - return ICCIDValidationResult{Valid: false, Message: "电信 ICCID 必须为 19 位"} - } - return ICCIDValidationResult{Valid: false, Message: "该运营商 ICCID 必须为 20 位"} - } - return ICCIDValidationResult{Valid: true, Message: ""} } -func getExpectedICCIDLength(carrierType string) int { - if carrierType == constants.CarrierCodeCTCC { - return 19 - } - return 20 -} - +// ValidateICCIDWithoutCarrier 验证 ICCID 格式(不依赖运营商类型) func ValidateICCIDWithoutCarrier(iccid string) ICCIDValidationResult { if iccid == "" { return ICCIDValidationResult{Valid: false, Message: "ICCID 不能为空"} @@ -54,10 +35,5 @@ func ValidateICCIDWithoutCarrier(iccid string) ICCIDValidationResult { return ICCIDValidationResult{Valid: false, Message: "ICCID 只能包含字母和数字"} } - length := len(iccid) - if length != 19 && length != 20 { - return ICCIDValidationResult{Valid: false, Message: "ICCID 长度必须为 19 位或 20 位"} - } - return ICCIDValidationResult{Valid: true, Message: ""} }