ShhPublicKeyValidator.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxAddon product developed. (Aug 23, 2018)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace ModulesGarden\Servers\ProxmoxVps\App\UI\Validators;
  20. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Validators\BaseValidator;
  21. /**
  22. * Description of NumberValidator
  23. *
  24. * @author Pawel Kopec <pawelk@modulesgardne.com>
  25. */
  26. class ShhPublicKeyValidator extends BaseValidator
  27. {
  28. protected $required = false;
  29. public function __construct($required = true)
  30. {
  31. $this->required = $required;
  32. }
  33. protected function validate($data, $additionalData = null)
  34. {
  35. if (!$this->required && empty($data))
  36. {
  37. return true;
  38. }
  39. else
  40. {
  41. if (!preg_match('/ssh\-/', $data))
  42. {
  43. $this->addValidationError('PleaseProvideASshPublicKey');
  44. return false;
  45. }
  46. }
  47. return true;
  48. }
  49. }