當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Validator::run方法代碼示例

本文整理匯總了PHP中Validator::run方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::run方法的具體用法?PHP Validator::run怎麽用?PHP Validator::run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Validator的用法示例。


在下文中一共展示了Validator::run方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: is_valid

 /**
  * Shorthand method for inline validation
  *
  * @param array $data The data to be validated
  * @param array $validators The GUMP validators
  * @return mixed True(boolean) or the array of error messages
  */
 public static function is_valid(array $data, array $validators)
 {
     $validator = new Validator();
     $validator->validation_rules($validators);
     if ($validator->run($data) === false) {
         return $validator->get_readable_errors(false);
     } else {
         return true;
     }
 }
開發者ID:sergey-sla,項目名稱:framework,代碼行數:17,代碼來源:Validator.php

示例2: mdControl

function mdControl($xmlSource)
{
    // podle jednoho validatoru
    if ($xmlSource == '') {
        return array();
    }
    include PHPINC_DIR . "/../validator/resources/Validator.php";
    $validator = new Validator("gmd", MICKA_LANG);
    $validator->run($xmlSource);
    $a = $validator->asArray();
    for ($i = 0; $i < count($a); $i++) {
        $d = explode('(', $a[$i]['description']);
        $a[$i]['description'] = $d[0];
    }
    return $a;
}
開發者ID:riskatlas,項目名稱:micka,代碼行數:16,代碼來源:micka_lib_xml.php

示例3: deleteAction

 public function deleteAction()
 {
     $params = Request::getParams();
     $validator = new Validator();
     $params = $validator->sanitize($params);
     $validator->validation_rules(array("id" => "required|numeric|checkIfRecordIdExists"));
     $validated_data = $validator->run($params);
     if ($validated_data === false) {
         Response::setStatus(404);
         $returnArray = array("error" => "Invalid data was sent", "messages" => $validator->get_readable_errors());
     } else {
         $model = new Model_Record();
         $model->delete($params['id']);
         Response::setStatus(204);
         $returnArray = array();
     }
     return $returnArray;
 }
開發者ID:blindly,項目名稱:ginger-pdns-api,代碼行數:18,代碼來源:Record.php

示例4: getCommandName

                }
            }
            $table->render();
        } else {
            $io->success('No issues found.');
        }
        return count($messages);
    }
}
final class Validator extends Application
{
    protected function getCommandName(InputInterface $input)
    {
        return 'validate';
    }
    protected function getDefaultCommands()
    {
        $defaultCommands = parent::getDefaultCommands();
        $defaultCommands[] = new Validate();
        return $defaultCommands;
    }
    public function getDefinition()
    {
        $inputDefinition = parent::getDefinition();
        $inputDefinition->setArguments();
        return $inputDefinition;
    }
}
$application = new Validator();
$application->run();
開發者ID:sensiolabs,項目名稱:security-advisories,代碼行數:30,代碼來源:validator.php

示例5: updateMd


//.........這裏部分代碼省略.........
                         $poly = $row['MD_VALUE'];
                     }
                     if ($row['MD_ID'] == 11 || $row['MD_ID'] == 5063) {
                         $title = $row['MD_VALUE'];
                         if ($lang_main == $row['LANG']) {
                             $title_lang_main = $row['MD_VALUE'];
                         }
                     }
                     break;
                 case 1:
                     if ($row['MD_ID'] == 14) {
                         $dc_geom = $row['MD_VALUE'];
                     }
                     if ($row['MD_ID'] == 11) {
                         $title = $row['MD_VALUE'];
                     }
                     break;
                 case 2:
                     if ($row['MD_ID'] == 11) {
                         $title = $row['MD_VALUE'];
                     }
                     break;
             }
         }
         $data = $data + $this->getGeom($x1, $y1, $x2, $y2, $poly, $dc_geom);
         $title = $title_lang_main != '' ? $title_lang_main : $title;
         $data['title'] = $title != '' ? $title : NULL;
     }
     $this->setMd($recno, $data);
     // update datestamp v md_values
     if ($this->md_record['md']['MD_STANDARD'] == 0 || $this->md_record['md']['MD_STANDARD'] == 10) {
         $this->setMdValuesDateStamp($this->md_record['md']['RECNO'], $this->md_record['md']['MD_STANDARD'], $update = TRUE);
     }
     // xmldata
     $xml = $this->getMdXmlData($this->md_record['md']['UUID']);
     if ($xml != '') {
         if (DB_DRIVER == 'oracle') {
             $conn = dibi::getConnection()->driver->getResource();
             setXmlToClob($conn, $this->table_md, 'xmldata', "recno={$recno}", $xml);
             //$data['pxml%sql'] = "XMLType('$xml')";
             //$data['xmldata'] = $xml;
         } elseif (DB_DRIVER == 'mssql2005') {
             // XMLDATA
             $data['xmldata'] = $xml;
         } elseif (DB_DRIVER == 'postgre') {
             // XMLDATA
             $data['xmldata'] = $xml;
         } elseif (DB_DRIVER == 'postgre_pxml') {
             $xml = str_replace("'", "&#39;", $xml);
             $data['pxml%sql'] = "XMLPARSE(DOCUMENT '{$xml}')";
         } else {
             $data['pxml'] = $xml;
         }
     }
     // --- validace XML ve vestavenem validatoru ---
     $data['valid'] = 0;
     $data['prim'] = 0;
     if (VALIDATOR == 1) {
         require_once WWW_DIR . '/validator/resources/Validator.php';
         $validator = new Validator();
         $validator->run($xml);
         $vResult = $validator->getPass();
         switch ($this->report_valid_type['type']) {
             case 'xml':
                 $this->md_record['report_valid'] = $validator->asXML($this->report_valid_type['short']);
                 break;
             case 'json':
                 $this->md_record['report_valid'] = $validator->asJSON();
                 break;
             case 'array':
                 $this->md_record['report_valid'] = $validator->asArray($this->report_valid_type['short']);
                 break;
             case 'html':
                 $this->md_record['report_valid'] = $validator->asHTML($this->report_valid_type['short']);
                 break;
             case 'htmlsmall':
                 $this->md_record['report_valid'] = $validator->asHTMLSmall($this->report_valid_type['short']);
                 break;
             default:
                 $this->md_record['report_valid'] = $validator->asHTML();
                 break;
         }
         if ($vResult) {
             if ($vResult['fail'] > 0) {
                 $data['valid'] = 0;
             } else {
                 if ($vResult['warn'] > 0) {
                     $data['valid'] = 1;
                 } else {
                     $data['valid'] = 2;
                 }
             }
             $data['prim'] = $vResult['primary'];
         }
         setMickaLog("VALIDACE valid=" . $data['valid'], 'DEBUG', 'MdRecord.updateMd');
     }
     $this->setMd($recno, $data);
     setXmldata2Pxml($this->table_md, $recno);
     return $rs;
 }
開發者ID:riskatlas,項目名稱:micka,代碼行數:101,代碼來源:MdRecord.php

示例6: catch

        }
        if (!strpos(strtolower($url), "request=")) {
            $url .= "&REQUEST=GetCapabilities";
        }
        //echo $url; exit;
    }
    try {
        $data = file_get_contents($url);
    } catch (Exception $e) {
        die("source not found.");
    }
}
if (!$data) {
    die("Data not entered");
}
$validator->run($data);
switch (htmlspecialchars($_REQUEST['format'])) {
    case "application/json":
        header("Content-type: application/json charset=\"utf-8\"");
        echo $validator->asJSON();
        break;
    case "application/xml":
        header("Content-type: application/xml charset=\"utf-8\"");
        echo $validator->result;
        break;
    case "array":
        var_dump($validator->asArray($short));
        break;
    default:
        if ($_REQUEST['head'] != 'false') {
            ?>
開發者ID:riskatlas,項目名稱:micka,代碼行數:31,代碼來源:validator.php

示例7: mainValid

function mainValid($uuid)
{
    $rs = array();
    $rs['akce'] = 'error';
    $rs['ok'] = FALSE;
    $rs['report'] = '';
    $rs['data'] = '';
    if ($uuid == '') {
        //$rs['report'] = 'Identifier not found!';
        //return $rs;
        require PHPINC_DIR . '/templates/404_record.php';
    }
    $table = 'md';
    $md_record = new MdRecord();
    $md_record->setTableMode($table);
    $record = $md_record->getMd('uuid', $uuid);
    if (is_array($record) && count($record) > 0) {
        if ($record['report'] == 'ok') {
            $rs['akce'] = '_valid';
            require_once WWW_DIR . '/validator/resources/Validator.php';
            $lang_valid = MICKA_LANG == 'cze' ? 'cze' : 'eng';
            $validator = new Validator('gmd', $lang_valid);
            $validator->run($record['md']['PXML']);
            $rs['data'] = $validator->asHTML();
            $rs['ok'] = TRUE;
        } else {
            //$rs['akce'] = 'error';
            //$rs['report'] = $record['report'];
            require PHPINC_DIR . '/templates/404_record.php';
        }
    }
    return $rs['data'];
}
開發者ID:riskatlas,項目名稱:micka,代碼行數:33,代碼來源:micka_main_lib.php

示例8: snippet

<?php

$validator = new Validator();
if (isset($_POST['submit'])) {
    $validator->add_rule('contactname', 'Name', 'required');
    $validator->add_rule('email', 'Email', 'required|email');
    $validator->add_rule('message', 'Message', 'required|min(5)');
    $validator->custom_message('email', 'required', "Please enter your email, this will only be used to respond to your message");
    $validator->custom_message('email', 'email', "Please enter a valid email, this will only be used to respond to your message");
    if ($validator->run() == true) {
        $email = new Email(array('to' => c::get('site_email'), 'from' => 'Aurer emailer <noreply@aurer.co.uk>', 'subject' => $validator->get_value('subject', 'Response from the Aurer site'), 'body' => $validator->get_value('contactname') . " sent you a message\n\n" . $validator->get_value('message') . "\n\n" . $validator->get_value('email'), 'service' => 'mailgun', 'options' => array('key' => c::get('mailgun_key'), 'domain' => c::get('mailgun_domain'))));
        if ($email->send()) {
            s::set('email_sent', true);
            go($page->url());
        } else {
            s::set('email_sent', false);
            message::set('mail_error', 'It appears your message cannot be sent right now, many appologies.', 'error');
            go($page->url());
        }
    }
}
?>

<?php 
echo snippet('header');
?>

<div class="section section--contact">
	<div class="section-inner">
		<h1><?php 
echo html($page->title());
開發者ID:aoimedia,項目名稱:aurer-kirby,代碼行數:31,代碼來源:contact.php

示例9: NewsFeed

/**
 * Created by PhpStorm.
 * User: Asus
 * Date: 5/30/2015
 * Time: 10:35 AM
 */
if (isset($_POST['save_feed'])) {
    require_once "../../includes/loader.php";
    if (isset($_POST['Id'])) {
        $feed = new NewsFeed(get_input("Id"));
    } else {
        $feed = new NewsFeed();
    }
    $validator = new Validator();
    $rules = array("Name" => "required", "PH_NO" => "required|numeric", "PostTitle" => "required", "PostDetail" => "required");
    $validator->run($rules);
    if (!$validator->fails()) {
        $feed->Name = get_input("Name");
        $feed->PH_NO = get_input("PH_NO");
        $feed->PostTitle = get_input("PostTitle");
        $feed->PostDetail = get_input("PostDetail");
        $feed->save();
        $messages = array("success" => 1, "message" => array("status" => "News Feed Sucessfully posted"));
    } else {
        $messages["message"] = $validator->getMessages();
        $messages["success"] = 0;
        Validator::reset();
    }
} else {
    $messages["message"] = array("status" => "Not enough Data Provided");
    $messages["success"] = 0;
開發者ID:amriterry,項目名稱:HelpNepal,代碼行數:31,代碼來源:save.php

示例10: reset

       reset($_REQUEST);
       //header("Pragma: no-cache");
       //header('Content-Disposition: attachment; filename="metadata_'.$_REQUEST['md']['fileIdentifier'].'.xml"');
       echo $cswClient->processTemplate($input, dirname(__FILE__) . '/resources/kote2iso.xsl', $params);
   } else {
       if ($_REQUEST["action-eu"]) {
           $xml = $cswClient->processTemplate($input, 'resources/kote2iso.xsl', $params);
           echo Kote::postFileForm(JRC_VALIDATOR, $xml);
       } else {
           if ($_REQUEST["action-cr"]) {
               echo '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
 	<link rel="stylesheet" type="text/css" href="../validator/style/validator.css"/></head><body>';
               $xml = $cswClient->processTemplate($input, dirname(__FILE__) . '/resources/kote2iso.xsl', $params);
               include dirname(__FILE__) . "/../validator/resources/Validator.php";
               $validator = new Validator();
               $validator->run($xml);
               echo $validator->asHTML();
           } else {
               if ($_REQUEST["action-html"]) {
                   echo "comming soon...";
                   //$s = $cswClient->processTemplate($input,'resources/kote2iso.xsl', $params);
                   //echo $cswClient->processTemplate($s,'../include/xsl/iso2html.xsl', $params);
               } else {
                   if ($_REQUEST["action-paspprint"]) {
                       $s = $cswClient->processTemplate($input, dirname(__FILE__) . 'resources/kote2iso.xsl', $params);
                       $par['komu'] = $_REQUEST['md']['komu'];
                       $par['cislo'] = $_REQUEST['md']['cislo'];
                       echo $cswClient->processTemplate($s, PHPPRG_DIR . '/../xsl/iso2pasport.xsl', $par);
                   } else {
                       if ($_REQUEST["action-pasport"]) {
                           echo $cswClient->processTemplateFile('', dirname(__FILE__) . '/resources/kote_pass.xsl');
開發者ID:riskatlas,項目名稱:micka,代碼行數:31,代碼來源:index.php


注:本文中的Validator::run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。