fix(notify): loose mobile phone number matching rules

This commit is contained in:
rainzm
2021-01-08 11:51:57 +08:00
parent cec10d3773
commit 64e79a934a
+4 -1
View File
@@ -17,6 +17,7 @@ package models
import (
"context"
"database/sql"
"regexp"
"time"
"yunion.io/x/jsonutils"
@@ -276,12 +277,14 @@ func (rm *SReceiverManager) ValidateCreateData(ctx context.Context, userCred mcc
return input, httperrors.NewInputParameterError("invalid email")
}
// validate mobile
if ok := regutils.MatchMobile(input.Mobile); len(input.Mobile) > 0 && !ok {
if ok := LaxMobileRegexp.MatchString(input.Mobile); len(input.Mobile) > 0 && !ok {
return input, httperrors.NewInputParameterError("invalid mobile")
}
return input, nil
}
var LaxMobileRegexp = regexp.MustCompile(`[0-9]{6,14}`)
func (r *SReceiver) IsEnabledContactType(ct string) (bool, error) {
if utils.IsInStringArray(ct, AllOkContactTypes) {
return true, nil