sfValidatorUrl.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfValidatorUrl validates Urls.
  11. *
  12. * @package symfony
  13. * @subpackage validator
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfValidatorUrl.class.php 9048 2008-05-19 09:11:23Z FabianLange $
  16. */
  17. class sfValidatorUrl extends sfValidatorRegex
  18. {
  19. /**
  20. * @param array $options An array of options
  21. * @param array $messages An array of error messages
  22. *
  23. * @see sfValidatorRegex
  24. */
  25. protected function configure($options = array(), $messages = array())
  26. {
  27. parent::configure($options, $messages);
  28. $this->setOption('pattern', '~^
  29. (https?|ftps?):// # http or ftp (+SSL)
  30. (
  31. ([a-z0-9-]+\.)+[a-z]{2,6} # a domain name
  32. | # or
  33. \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address
  34. )
  35. (:[0-9]+)? # a port (optional)
  36. (/?|/\S+) # a /, nothing or a / with something
  37. $~ix');
  38. }
  39. }