<?php require_once "../raxan/pdi/autostart.php"; // add custom phone and money validators $san = Raxan::dataSanitizer(); $san->addDataValidator('Phone', '/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/'); // using regex $san->addDataValidator('ZipCode', 'validate_ZipCode'); // using callback function validate_ZipCode($value) { // validate zip code return preg_match('/^(\\d{5}-\\d{4})|(\\d{5})$/', $value); } class CustomValidatorPage extends RaxanWebPage { protected $frm; protected function _config() { $this->preserveFormContent = true; } protected function _init() { $this->source('views/custom-validators.html'); } protected function formSubmit($e) { // event callback $msg = array(); // validate user input if (!$this->post->isPhone('phone')) {
function testDataSanitizer() { $html = '<b>string</b>'; $d = Raxan::dataSanitizer(); $this->ok($d instanceof RaxanDataSanitizer, 'Instance of DataSanitzer'); $d = Raxan::dataSanitizer(array('int' => 1234, 'text' => 'string', 'html' => $html)); $this->compare($d->integer('int'), 1234, 'Read data from sanitizer'); $this->compare($d->text('text'), 'string', 'Read text data from sanitizer'); $this->compare($d->text('html'), 'string', 'Read (sanitzed)html data from sanitizer'); $this->compare($d->value('html'), $html, 'Read (raw) data value from sanitizer'); }
/** * Returns data sanitizer object with get and/or post values. Defaults to post values * @deprecated deprecated since 1.0 rc1. Use post and get properties * @see RaxanWebPage->post and RaxanWebPage->get * @return RaxanDataSanitizer */ public function sanitizePostBack($incGETRequest = false) { $array = $incGETRequest ? array_merge($_GET, $_POST) : null; if (!isset($this->_postRqst)) { $this->_postRqst = Raxan::dataSanitizer($array, $this->_charset); } return $this->_postRqst; }