• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/form/schedule/calendarform.php
  • Класс: BitrixTimemanFormScheduleCalendarForm
  • Вызов: CalendarForm::getDatesJsonValidateCallback
private function getDatesJsonValidateCallback(): callable
{
	return function ($value)
	{
		if ($this->isEmptyValue($value))
		{
			return true;
		}
		if (is_array($value))
		{
			return false;
		}

		try
		{
			$decoded = Json::decode($value);
		}
		catch (Exception $exc)
		{
			return false;
		}

		if (!is_array($decoded))
		{
			return false;
		}
		foreach ($decoded as $year => $months)
		{
			if (!is_numeric($year) || $year > 2500 || $year < 2000)
			{
				return false;
			}
			foreach ($months as $month => $days)
			{
				if (!is_numeric($month) || $month < 0 || $month > 11)
				{
					return false;
				}
				foreach ((array)$days as $day => $time)
				{
					if (!is_numeric($month) || $day < 0 || $day > 31)
					{
						return false;
					}
					if (!is_numeric($time))
					{
						return false;
					}
				}
			}
		}
		return true;
	};
}