1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-31 19:30:21 +02:00
- Add tests for the atoms.
- Add Id validation for Directives

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1623 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-22 21:06:55 +00:00
parent 34ba0e408f
commit b8f00ace1a
4 changed files with 98 additions and 19 deletions

View File

@@ -3,15 +3,15 @@
/**
* Fluent interface for validating the contents of member variables.
* This should be immutable. See HTMLPurifier_ConfigSchema_Validator for
* use-cases.
* use-cases. We name this an 'atom' because it's ONLY for validations that
* are independent and usually scalar.
*/
class HTMLPurifier_ConfigSchema_ValidatorAtom
{
protected $interchange, $context, $obj, $member, $contents;
protected $context, $obj, $member, $contents;
public function __construct($interchange, $context, $obj, $member) {
$this->interchange = $interchange;
public function __construct($context, $obj, $member) {
$this->context = $context;
$this->obj = $obj;
$this->member = $member;
@@ -24,11 +24,12 @@ class HTMLPurifier_ConfigSchema_ValidatorAtom
}
public function assertNotNull() {
if (is_null($this->contents)) $this->error('must not be null');
if ($this->contents === null) $this->error('must not be null');
return $this;
}
public function assertAlnum() {
$this->assertIsString();
if (!ctype_alnum($this->contents)) $this->error('must be alphanumeric');
return $this;
}