| Current Path : /home/smartconb/www/armencom33/administrator/components/com_dpcalendar/models/rules/ |
| Current File : /home/smartconb/www/armencom33/administrator/components/com_dpcalendar/models/rules/decimal.php |
<?php
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormRule;
/**
* @package DPCalendar
* @copyright Copyright (C) 2017 Digital Peak GmbH. <https://www.digital-peak.com>
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\Registry\Registry;
class JFormRuleDecimal extends FormRule
{
public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
{
// If the field is empty and not required, the field is valid.
$required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required');
if (!$required && empty($value)) {
return true;
}
return is_numeric($value) || is_float($value);
}
}