mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-30 19:00:10 +02:00
Refactor validators so that they can be reused between directives and namespaces.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1589 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
22
library/HTMLPurifier/ConfigSchema/Validator/Alnum.php
Normal file
22
library/HTMLPurifier/ConfigSchema/Validator/Alnum.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Validates that a field is alphanumeric in the array (does not check
|
||||
* existence!)
|
||||
*/
|
||||
class HTMLPurifier_ConfigSchema_Validator_Alnum extends HTMLPurifier_ConfigSchema_Validator
|
||||
{
|
||||
|
||||
protected $index;
|
||||
|
||||
public function __construct($index) {
|
||||
$this->index = $index;
|
||||
}
|
||||
|
||||
public function validate(&$arr, $interchange) {
|
||||
if (!ctype_alnum($arr[$this->index])) {
|
||||
throw new HTMLPurifier_ConfigSchema_Exception($arr[$this->index] . ' in '. $this->index .' must be alphanumeric');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user