当前位置: 首页>>代码示例>>PHP>>正文


PHP validator::validate方法代码示例

本文整理汇总了PHP中validator::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP validator::validate方法的具体用法?PHP validator::validate怎么用?PHP validator::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validator的用法示例。


在下文中一共展示了validator::validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 public function validate($file = '', $rule = '', $encode = 'utf8', $VAL = null)
 {
     q4mController::useHelper('validator');
     if ($file == '') {
         $file = str_replace('Model', '', get_class($this)) . 'Rules.php';
     }
     if ($rule == '') {
         $rule = str_replace('Model', '', get_class($this));
     }
     if (file_exists(_SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php')) {
         include_once _SETTINGS_DIR_ . $file . 'Rules.php';
         if (!isset(${$rule}) || !count(${$rule})) {
             q4mSystem::haltOnError('The requested rule "' . ${$rule} . '" is empty in ', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
             exit;
         }
     } else {
         q4mSystem::haltOnError('The file is not found', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
         exit;
     }
     $rules = ${$rule};
     $vc = new validator($rules, $encode, $VAL);
     if (count($vc->RULES)) {
         foreach ($vc->RULES as $key => $SV) {
             $vc->validate($key);
         }
     }
     if (count($vc->ERRORS)) {
         return $vc->ERRORS;
     } else {
         return false;
     }
 }
开发者ID:spraynakama,项目名称:q4m_framework,代码行数:32,代码来源:class.q4mModel.php

示例2: forms

   $country_list = (require_once $current_dir . "/protected/components/CountryCode.php");
   $forms = new forms();
   $currency_list = array('AUD' => "AUD-$", 'CAD' => "CAD-$", 'CNY' => "CNY-¥", 'EUR' => "EUR-€", 'HKD' => "HKD-$", 'JPY' => "JPY-¥", 'MXN' => "MXN-$", 'USD' => "USD-$", 'NZD' => "NZD-$");
   $currency_list = array_flip($currency_list);
   ?>
 
 <?php 
   if ($_SERVER['REQUEST_METHOD'] == 'POST') {
       ?>
 <?php 
       $err = '';
       $data = $_POST;
       $req = array('website_title' => "Website title is required", 'admin_country_set' => "Country is required", 'website_address' => "Address is required", 'website_contact_phone' => "Phone is required", 'website_contact_email' => "Email is required", 'admin_currency_set' => "Currency is required", 'username' => "Username is required", 'password' => "Password is required");
       $validator = new validator();
       $validator->required($req, $data);
       if ($validator->validate()) {
           $admin_currency_set = explode("-", $data['admin_currency_set']);
           $db_con = $_SESSION['kr_install_data'];
           $table_prefix = isset($db_con['db_table_prefix']) ? $db_con['db_table_prefix'] : '';
           $table_prefix = !empty($table_prefix) ? $table_prefix : "mt_";
           require_once $current_dir . "/protected/config/table_structure.php";
           require_once $current_dir . "/install/class.MySQL.php";
           echo "<p class=\"uk-icon-chevron-right\"> Connecting to database..</p>";
           //$db = new Db( 'mysql', $db_con['db_host'], $db_con['db_name'], $db_con['db_username'],$db_con['db_pass'] );
           $db = new MySQL($db_con['db_name'], $db_con['db_username'], $db_con['db_pass'], $db_con['db_host']);
           echo "<div>Connection [ok]</div>";
           echo "<p class=\"uk-icon-chevron-right\"> Saving information ...</p>";
           $params = array('website_title' => $data['website_title'], 'admin_country_set' => $data['admin_country_set'], 'website_address' => $data['website_address'], 'website_contact_phone' => $data['website_contact_phone'], 'website_contact_email' => $data['website_contact_email'], 'admin_currency_set' => $admin_currency_set[0]);
           $truncate = "TRUNCATE TABLE " . $table_prefix . "option";
           $db->raw($truncate);
           try {
开发者ID:ashishvazirani,项目名称:food,代码行数:31,代码来源:install2.php

示例3: array

<?php

// Require app files
require 'app/User.php';
require 'app/Validator.php';
require 'app/Helper.php';
//Set data and validation rules
$rules = array('email' => 'required|email', 'password' => 'required|min:8');
$data = array('email' => 'joost@tutsplus.com', 'password' => '12346789', 'foo' => 'bar');
// Run validation
$validator = new validator();
if ($validator->validate($data, $rules) == true) {
    //Validation passed. Set user values.
    $joost = new User($data);
    $joost->email = 'sometheremail@tutsplus.com';
    $joost->password = 'sadfsadfsad';
    //var_dump($joost->email);
    //var_dump($joost->password);
    //Dump user
    // var_dump($joost);
    echo $joost;
} else {
    // Validation failed. Dump validation errors.
    var_dump($validator->getErrors());
}
开发者ID:alfiatul,项目名称:php-oop-fundamental,代码行数:25,代码来源:index.php

示例4: array

<head>
<title>Gmail</title>

<script type="text/javascript" src="../js/registration.js"></script> 
<script type="text/javascript" src="../js/common.js"></script> 
<link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>
<body>
	<h1 align="center">Gmail</h1>
	<h2 align="center">signup</h2>
	<?php 
if (!empty($_POST)) {
    require_once 'function.php';
    $errors = array();
    $validatorObj = new validator($_POST);
    $validatorObj->validate();
    if ($validatorObj->getIsValid()) {
        // create user object for OOP manipulation
        $userObj = new User($_POST);
    } else {
        $errors = $validatorObj->getErrors();
    }
}
if (!empty($errors)) {
    ?>
<p> errors occured:please check</p>
<p class="error">
<?php 
    if (is_array($errors)) {
        foreach ($errors as $val) {
            echo $val . '<br />';
开发者ID:sathish-narayanan,项目名称:lamp,代码行数:31,代码来源:signup.php


注:本文中的validator::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。