174 parent::checkFields($result, $primary, $data);
175 $pushManager = new \CPushManager();
176 $availableDataTypes = array_keys($pushManager->getServices());
180 $entity = self::getEntity();
181 $tokensReceived = !empty($data[
"DEVICE_TOKEN"]) || !empty($data[
"VOIP_TOKEN"]);
182 $checkToken =
function($token) {
183 return $token ==
null || preg_match(
'~^[a-f0-9]{64}$~i', $token);
186 if (!$data[
"DEVICE_TYPE"] || !in_array($data[
"DEVICE_TYPE"], $availableDataTypes))
188 $result->
addError(
new Entity\
FieldError($entity->getField(
"DEVICE_TYPE"),
"Wrong field value", FieldError::INVALID_VALUE));
192 $result->
addError(
new Entity\
FieldError($entity->getField(
"DEVICE_TYPE"),
"Tokens were not received", FieldError::INVALID_VALUE));
195 if ($data[
"DEVICE_TYPE"] ==
"APPLE")
197 if (!$checkToken($data[
"DEVICE_TOKEN"]) || !$checkToken($data[
"DEVICE_TOKEN_VOIP"]))
198 $result->
addError(
new Entity\
FieldError($entity->getField(
"DEVICE_TYPE"),
"Wrong format of token for iOS", FieldError::INVALID_VALUE));