-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:LitusProject/Litus
- Loading branch information
Showing
4 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* Litus is a project by a group of students from the KU Leuven. The goal is to create | ||
* various applications to support the IT needs of student unions. | ||
* | ||
* @author Niels Avonds <[email protected]> | ||
* @author Karsten Daemen <[email protected]> | ||
* @author Koen Certyn <[email protected]> | ||
* @author Bram Gotink <[email protected]> | ||
* @author Dario Incalza <[email protected]> | ||
* @author Pieter Maene <[email protected]> | ||
* @author Kristof Mariën <[email protected]> | ||
* @author Lars Vierbergen <[email protected]> | ||
* @author Daan Wendelen <[email protected]> | ||
* @author Mathijs Cuppens <[email protected]> | ||
* @author Floris Kint <[email protected]> | ||
* | ||
* @license http://litus.cc/LICENSE | ||
*/ | ||
|
||
namespace TicketBundle\Component\Validator; | ||
|
||
/** | ||
* Check the option is valid to use in a url | ||
* | ||
* @author Kristof Mariën <[email protected]> | ||
*/ | ||
class UrlValid extends \CommonBundle\Component\Validator\AbstractValidator | ||
{ | ||
const NOT_VALID = 'notValid'; | ||
|
||
/** | ||
* Error messages | ||
* | ||
* @var array | ||
*/ | ||
protected $messageTemplates = array( | ||
self::NOT_VALID => 'The option can\'t contain the following characters: & + . #', | ||
); | ||
|
||
/** | ||
* Sets validator options | ||
* | ||
* @param integer|array|\Traversable $options | ||
*/ | ||
public function __construct($options = array()) | ||
{ | ||
parent::__construct($options); | ||
} | ||
|
||
/** | ||
* Returns true if the format is right | ||
* | ||
* @param string $value The value of the field that will be validated | ||
* @param array|null $context The context of the field that will be validated | ||
* @return boolean | ||
*/ | ||
public function isValid($value, $context = null) | ||
{ | ||
$this->setValue($value); | ||
|
||
if (!is_string($value)) { | ||
return false; | ||
} | ||
|
||
if(str_contains($value,'&') or str_contains($value,'+') or str_contains($value,'.') or str_contains($value,'#')) | ||
|
||
$this->error(self::NOT_VALID); | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters