| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /* * ********************************************************************
- * ProxmoxAddon product developed. (Aug 23, 2018)
- * *
- *
- * CREATED BY MODULESGARDEN -> http://modulesgarden.com
- * CONTACT -> contact@modulesgarden.com
- *
- *
- * This software is furnished under a license and may be used and copied
- * only in accordance with the terms of such license and with the
- * inclusion of the above copyright notice. This software or any other
- * copies thereof may not be provided or otherwise made available to any
- * other person. No title to and ownership of the software is hereby
- * transferred.
- *
- *
- * ******************************************************************** */
- namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Validators;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Validators\BaseValidator;
- /**
- * Description of NumberValidator
- *
- * @author Pawel Kopec <pawelk@modulesgardne.com>
- */
- class VirtualIpAddressValidator extends BaseValidator
- {
- protected $required = false;
- protected $public = true;
- public function __construct($required = false , $public = true)
- {
- $this->required = $required;
- $this->public = $public;
- }
- protected function validate($data, $additionalData = null)
- {
- if (!$this->required && empty($data))
- {
- return true;
- }
- if (!filter_var($data, FILTER_VALIDATE_IP))
- {
- $this->addValidationError('IP Address is not valid', false);
- return false;
- }
- if (!$this->public && filter_var($data, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE))
- {
- $this->addValidationError('The IP Address is not private', false);
- return false;
- }
- //@todo
- // if ($this->required && VmIpAddress::ofIp($data)->count())
- // {
- // $this->addValidationError('IP Address already exist', false);
- // return false;
- // }
- return true;
- }
- }
|