示例#1
0
 /**
  * Check rules on given file.
  *
  * @param  Array  $_FILES superarray.
  * @param  String Index of file to check in $_FILES array.
  * @return Boolean
  */
 function validate($files, $index)
 {
     if (is_array($files) && isset($files[$index])) {
         $this->addRule(new Rule_File());
         return parent::validate($files[$index]);
     } elseif ($this->isRequired) {
         return false;
     } else {
         return true;
     }
 }
示例#2
0
 /**
  * Need to throw an error if the value is required but the rule return true
  * even with empty values
  */
 function testRequiredAndPermissive()
 {
     $r =& new MockRule($this);
     $r->setReturnValue('isValid', true);
     $v = new Valid();
     $v->disableFeedback();
     $v->required();
     $v->addRule($r);
     $this->assertFalse($v->validate(''));
 }
<?php

$objDB = new DataBase();
$objLang = new Lang();
$objAccess = new Access($objDB);
$objValid = new Valid($objDB, $objLang->text);
if (filter_input(INPUT_POST, 'action') === 'reg') {
    if ($objValid->validate()) {
        $objDB->addUser($objValid->request);
    }
} else {
    $objValid->clear();
}
$accessType = $objAccess->accessType;
$page = $objAccess->page;
$text = $objLang->text;
$errors = $objValid->errorText();
$fields = $objValid->request;
include_once 'header_view.php';
include_once 'registration_view.php';
include_once 'footer_view.php';