16 lines
281 B
Go
16 lines
281 B
Go
package phone
|
|
|
|
import (
|
|
"backend/pkg/errors"
|
|
"regexp"
|
|
)
|
|
|
|
func IsValid(value string) (bool, error) {
|
|
re := regexp.MustCompile(`^(?:0|\+98|0098)(\d{10})$`)
|
|
result := re.FindStringSubmatch(value)
|
|
if len(result) > 0 {
|
|
return true, nil
|
|
}
|
|
return false, errors.ErrPhoneInvalid
|
|
}
|