Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
validator.php
1<?php
9
11
12Loc::loadMessages(__FILE__);
13
19{
27 public static function validate($code, $typeId = Type::EMAIL)
28 {
29 switch ($typeId)
30 {
31 case Type::IM:
32 return self::validateIm($code);
33
34 case Type::PHONE:
35 return self::validatePhone($code);
36
37 case Type::CRM_CONTACT_ID:
38 case Type::CRM_COMPANY_ID:
39 return self::validateCrmEntityId($code);
40
41 case Type::EMAIL:
42 default:
43 return self::validateEmail($code);
44 }
45 }
46
53 public static function validateEmail($email)
54 {
55 return check_email($email);
56 }
57
64 public static function validatePhone($phone)
65 {
66 return (bool) preg_match('/^[\+]?[\d]{4,25}$/', $phone);
67 }
68
75 public static function validateIm($code)
76 {
77 return (bool) preg_match('/^[\d]+\|[\d]+$/', $code);
78 }
79
86 public static function validateCrmEntityId($code)
87 {
88 return (bool) preg_match('/^[\d]$/', $code);
89 }
90}
static loadMessages($file)
Definition loc.php:64
static validate($code, $typeId=Type::EMAIL)
Definition validator.php:27