0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-09-20 19:25:19 +00:00
htmlpurifier/library/HTMLPurifier/ConfigSchema/Validator/Alnum.php

23 lines
561 B
PHP

<?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');
}
}
}