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


PHP GUMP::is_valid方法代码示例

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


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

示例1: delete

 public function delete()
 {
     $options = WebApp::post('options') === NULL ? array() : strgetcsv(WebApp::post('options'));
     if (count($options) == 0) {
         return new ActionResult($this, '/admin/core/option_view', 0, 'No option(s) were selected!', B_T_FAIL);
     }
     foreach ($options as $option) {
         $validated = GUMP::is_valid(array('opt' => $option), array('opt' => 'integer'));
         if ($validated !== true) {
             return new ActionResult($this, '/admin/core/option_view', 0, 'No option(s) were selected!', B_T_FAIL);
         }
     }
     $delete = $this->mySQL_w->prepare("DELETE FROM `core_options` WHERE `id`=?");
     $affected_rows = 0;
     foreach ($options as $id) {
         $delete->bind_param('i', $id);
         $delete->execute();
         $delete->store_result();
         $affected_rows += $delete->affected_rows;
     }
     if ($affected_rows == count($options)) {
         $this->parent->parent->logEvent($this::name_space, 'Deleted options: ' . csvgetstr($options));
         return new ActionResult($this, '/admin/core/option_view', 1, 'Successfully deleted selected option(s)!', B_T_SUCCESS);
     } else {
         $this->parent->parent->logEvent($this::name_space, 'Deleted some options: ' . csvgetstr($options));
         return new ActionResult($this, '/admin/core/option_view', 1, 'Successfully deleted ' . $affected_rows . '/' . count($options) . ' selected option(s)!<br /><small>Possible cause: <code>Unknown</code></small>', B_T_WARNING);
     }
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:28,代码来源:option.action.php

示例2: validate

 public static function validate($validation, $value, $type)
 {
     $rules = array('required');
     if (array_key_exists('email', $validation)) {
         array_push($rules, 'valid_email');
     }
     if (array_key_exists('starts', $validation)) {
         array_push($rules, 'starts,' . $validation['starts']);
     }
     if (array_key_exists('regex', $validation)) {
         $regex = is_array($validation['regex']) ? implode(',', $validation['regex']) : $validation['regex'];
         error_log($regex);
         error_log($value);
         if (!preg_match($regex, $value)) {
             return false;
         }
     }
     if ($type == 'string') {
         if (array_key_exists('maxLength', $validation)) {
             array_push($rules, 'max_len,' . $validation['maxLength']);
         }
         if (array_key_exists('minLength', $validation)) {
             if ($validation['minLength'] === 0 && strlen($value) == 0) {
                 return true;
             }
             array_push($rules, 'min_len,' . $validation['minLength']);
         }
     } else {
         if ($type == 'integer' || $type == 'timestamp') {
             if ($type == 'integer') {
                 array_push($rules, 'integer');
             }
             if (array_key_exists('min', $validation)) {
                 array_push($rules, 'min_numeric,' . $validation['min']);
             }
             if (array_key_exists('max', $validation)) {
                 array_push($rules, 'max_numeric,' . $validation['max']);
             }
         }
     }
     if (count($rules) == 1) {
         return true;
     }
     $valid = \GUMP::is_valid(array('temp' => $value), array('temp' => implode('|', $rules)));
     return $valid === true;
 }
开发者ID:stenvala,项目名称:deco-essentials,代码行数:46,代码来源:Validation.php

示例3: run

 /**
  * @param array $params
  * @param array $files
  * @return array
  */
 public function run($params = array(), $files = array())
 {
     // Siga esse modelo para retornar erros
     $error = array("error" => false, "errorInfo" => "", "errorDesc" => "", "errorFields" => array());
     // Roda validação de campos simples
     foreach ($this->postRules as $field => $rule) {
         $data = array();
         $data[$field] = $rule;
         $validated = \GUMP::is_valid($params, $data);
         if ($validated !== true) {
             $error['errorFields'][] = $field;
         }
     }
     foreach ($this->fileRules as $field => $rule) {
         if (isset($files[$field]['name']) && !empty($files[$field]['name'])) {
             $storage = new FileSystem('public/uploads', BASEPATH);
             $file = new File($field, $storage);
             $file->setName(uniqid());
             $file->addValidations(array(new \Upload\Validation\Extension($rule['extension']), new \Upload\Validation\Size($rule['size'])));
             $name = $file->getNameWithExtension();
             try {
                 $file->upload();
                 $params[$field] = $name;
             } catch (\Exception $e) {
                 $error['errorFields'][] = $field;
             }
         } else {
             if (!isset($params[$field]) || empty($params[$field])) {
                 $error['errorFields'][] = $field;
             }
         }
     }
     if (!empty($error['errorFields'])) {
         $error['error'] = true;
         $error['errorInfo'] = "Erro ao salvar registro.";
         $error['errorDesc'] = "Preencha todos os campos corretamente";
         return array_merge_recursive($error, $params);
     } else {
         // Roda os tratamentos
         return $this->treatment($params, $files);
     }
 }
开发者ID:kayo-almeida,项目名称:silex-modular-skeleton,代码行数:47,代码来源:UsuariosValidation.php

示例4: error_reporting

#!/usr/bin/php -q
<?php 
error_reporting(-1);
ini_set('display_errors', 1);
require "../gump.class.php";
$data = array('street' => '6 Avondans Road');
$validated = GUMP::is_valid($data, array('street' => 'required|street_address'));
if ($validated === true) {
    echo "Valid Street Address\n";
} else {
    print_r($validated);
}
开发者ID:guimafx,项目名称:GUMP,代码行数:12,代码来源:street_address.php

示例5: error_reporting

#!/usr/bin/php -q
<?php 
error_reporting(-1);
ini_set('display_errors', 1);
require "../gump.class.php";
$data = array('one' => 'Freiheit, Mobilität und Unabhängigkeit lebt. ö, Ä, é, or ß', 'two' => 'ß');
$validated = GUMP::is_valid($data, array('one' => 'required|min_len,10', 'two' => 'required|min_len,1'));
if ($validated === true) {
    echo "Valid Text\n";
} else {
    print_r($validated);
}
开发者ID:lanlin,项目名称:GUMP,代码行数:12,代码来源:utf-8.php

示例6: error_reporting

#!/usr/bin/php -q
<?php 
error_reporting(-1);
ini_set('display_errors', 1);
require "../gump.class.php";
$data = array('str' => null);
$rules = array('str' => 'required');
GUMP::set_field_name("str", "Street");
$validated = GUMP::is_valid($data, $rules);
if ($validated === true) {
    echo "Valid Street Address\n";
} else {
    print_r($validated);
}
开发者ID:lanlin,项目名称:GUMP,代码行数:14,代码来源:explicit_fields.php

示例7: sendMailchimp

function sendMailchimp($formData, $config)
{
    $validated = GUMP::is_valid($formData, array('newsletter-name' => 'required', 'newsletter-email' => 'required|valid_email'));
    if ($validated === true) {
        $Mailchimp = new Mailchimp($config['mailchimp_api_key']);
        $Mailchimp_Lists = new Mailchimp_Lists($Mailchimp);
        $email = $formData['newsletter-email'];
        //replace with a test email
        $name = $formData['newsletter-name'];
        //replace with a test email
        try {
            $subscriber = $Mailchimp_Lists->subscribe($config['mailchimp_list_id'], array('email' => $email, 'name' => $name));
            //pass the list id and email to mailchimp
        } catch (Exception $e) {
            $result = array('result' => 'error', 'msg' => $e->getMessage());
            return json_encode($result);
        }
        // check that we've succeded
        if (!empty($subscriber['leid'])) {
            $result = array('result' => 'success', 'msg' => array('Success! Thank you for signing up to our newsletter.'));
            return json_encode($result);
        }
    } else {
        $result = array('result' => 'error', 'msg' => $validated);
        return json_encode($result);
    }
}
开发者ID:markcameron,项目名称:mum,代码行数:27,代码来源:index.php

示例8: CONCAT

<?php

if (WebApp::get('cat4') !== NULL) {
    $option_query = $mySQL_r->prepare("SELECT `core_ip`.`ID`,`time`, CONCAT(`f_name`, ' ', `s_name`, ' (', `username`, ')'),  INET_NTOA(`ip`), `length`,`reason` FROM `core_ip`\nLEFT JOIN `core_users`\nON `user_id`=`core_users`.`id`\nWHERE `core_ip`.`ID`=?\n");
    if (GUMP::is_valid(array('id' => WebApp::get('cat4')), array('id' => 'required|integer'))) {
        $id = WebApp::get('cat4');
        $option_query->bind_param('i', $id);
        $option_query->execute();
        $option_query->bind_result($block_id, $time, $user, $ip, $length, $reason);
        $option_query->store_result();
        if ($option_query->num_rows == 1) {
            $option_query->fetch();
        } else {
            $page->setStatus(404);
            return;
        }
    } else {
        $page->setStatus(404);
        return;
    }
} else {
    $page->setStatus(404);
    return;
}
$closeBtn = array('a' => array('t' => 'url', 'a' => '../ipblock_view'), 'ic' => 'remove-sign');
$saveBtn = array('s' => B_T_SUCCESS, 'a' => array('t' => 'url', 'a' => '#', 'oc' => 'processForm(\'ipblock_edit\', this, \'save\')'), 'ic' => 'floppy-disk');
$applyBtn = array('s' => B_T_PRIMARY, 'a' => array('t' => 'url', 'a' => '#', 'oc' => 'processForm(\'ipblock_edit\', this, \'apply\')'), 'ic' => 'ok-sign');
$form = $page->getPlugin('form', array('ipblock_edit', WebApp::action('core', 'ipblock_edit', true), 'post'));
$form->setColumns(2, 6)->setIndent('    ')->addTextField('Block ID', 'id', $block_id, array(), array('ro' => true))->addTextField('Block Created', 'time', date(DATET_LONG, strtotime($time)), array('t' => 'Time the block was created'), array('ro' => true))->addTextField('User', 'user', $user, array('t' => 'User that created the block.'), array('ro' => true))->addTextField('IP Address', 'ip', $ip, array('t' => 'IP Address to block.', 'p' => 'xyz.xyz.xyz.xyz'), array('ro' => true))->addTextField('Length', 'length', $length, array('t' => 'Length of block in days.', 'p' => 'Days to block'), array('v' => true, 'vm' => array('textfieldRequiredMsg' => array('m' => 'Length of block is required.', 's' => 'danger')), 'vo' => 'validateOn:["blur"]', 'd' => false, 'r' => true, 'vt' => 'integer', 't' => 'number'))->addTextField('Reason', 'reason', $reason, array('t' => 'Reason for block.', 'p' => 'Reason'), array('v' => true, 'vm' => array('textfieldRequiredMsg' => array('m' => 'A Reason is required.', 's' => B_T_FAIL), 'textfieldMinCharsMsg' => array('m' => 'A Reason is required.', 's' => B_T_FAIL), 'textfieldMaxCharsMsg' => array('m' => 'Reason is limited to 255 chars.', 's' => B_T_FAIL)), 'vo' => 'minChars: 0, maxChars: 255, validateOn:["blur"]', 'r' => true))->addBtnLine(array('close' => $closeBtn, 'save' => $saveBtn, 'apply' => $applyBtn));
$form->build();
?>
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:31,代码来源:ipblock_edit.php

示例9: htmlentities

 	{
 	    $validated_data[$key] = htmlentities($val);
 	}
 }
 echo '<pre>';var_dump($validated_data);echo '</pre>';
 */
 if ($validated_data === false) {
     $errors = $gump->validate($app->request->post(), $validation_rules_2);
     if (!is_array($errors)) {
         $errors = [];
     }
     $validate_username = GUMP::is_valid(['username' => $app->request->post('username')], ['username' => 'istaken']);
     if ($validate_username !== true) {
         $errors[] = array('field' => 'username', 'value' => '', 'rule' => 'validate_istaken', 'param' => '');
     }
     $validate_email = GUMP::is_valid(['email' => $app->request->post('email')], ['email' => 'istaken']);
     if ($validate_email !== true) {
         $errors[] = array('field' => 'email', 'value' => '', 'rule' => 'validate_istaken', 'param' => '');
     }
     if ($app->request->post('password') !== $app->request->post('password_confirm')) {
         $errors[] = array('field' => 'password_confirm', 'value' => '', 'rule' => 'validate_password_confirm', 'param' => '');
     }
     if (is_array($errors)) {
         foreach ($errors as $k => $v) {
             $transfield = $app->translator->trans('user.signup.form.' . $v['field']);
             $transerrors[$v['field']][] = $app->translator->trans('user.error.' . $v['rule'] . ' %field% %param%', ['%field%' => $transfield, '%param%' => $v['param']]);
         }
     }
     $app->render('login/signup.php', ['errors' => $errors, 'transerrors' => $transerrors, 'post' => $post]);
 } else {
     # TODO try catch loop
开发者ID:WebstudioNoord,项目名称:notes,代码行数:31,代码来源:user.router.php

示例10: session_start

session_start();
$gump = new GUMP();
$_POST = $gump->sanitize($_POST);
// You don't have to sanitize, but it's safest to do so.
$gump->validation_rules(array('depart' => 'required|max_len,90|min_len,5', 'destination' => 'required|max_len,90|min_len,5', 'passager' => 'required|max_len,40|min_len,5', 'retour' => 'required|alpha_dash|max_len,20|min_len,4', 'clientName' => 'required|alpha_space|max_len,40|min_len,2', 'clientEmail' => 'required|valid_email', 'clientTel' => 'required|numeric|max_len,15|min_len,5', 'clientType' => 'required|max_len,90|min_len,4', 'clientPickUP' => 'required|date', 'clientPickTimeHUP' => 'required|numeric|max_len,2', 'clientPickTimeMUP' => 'required|numeric|max_len,2'));
$validated_data = $gump->run($_POST);
if ($validated_data === false) {
    $chaine = "Les données entrées sont erronés : <br>";
    foreach ($gump->get_errors_array() as $strings) {
        $chaine = $chaine . $strings . '<br>';
    }
    $_SESSION['aERROR'] = $chaine;
    Redirect('reservation.php', false);
} else {
    if ($_POST['retour'] == "Aller-Retour" && (!isset($_POST['clientPickBackUP']) || !isset($_POST['clientPickBackTimeHUP']) || !isset($_POST['clientPickBackTimeMUP']))) {
        $is_valid = GUMP::is_valid($_POST, array('clientPickBackUP' => 'required|date', 'clientPickBackTimeHUP' => 'required|numeric|max_len,2', 'clientPickBackTimeMUP' => 'required|numeric|max_len,2'));
        if (!($is_valid === true)) {
            $_SESSION['aERROR'] = "Vous avez choisi un Aller-Retour mais vous n'avez pas spécifié le champ <strong>Temps Retour</strong> ";
            Redirect('reservation.php', false);
        }
    }
    $consumer = new Consumer();
    $consumer->setName($_POST['clientName']);
    $consumer->setEmail($_POST['clientEmail']);
    $consumer->setTelephone($_POST['clientTel']);
    $consumer->setType(getConsumerTypeByName($_POST['clientType']));
    EManager::getEntityManager()->persist($consumer);
    EManager::getEntityManager()->flush();
    $station_depart = getStationObjByName($_POST['depart']);
    $station_destination = getStationObjByName($_POST['destination']);
    $reservation = new Reservation();
开发者ID:anouarattn,项目名称:projet_nabil,代码行数:31,代码来源:processReservation.php

示例11: array

#!/usr/bin/php -q
<?php 
require "../gump.class.php";
$_FILES = array('attachments' => array('name' => array("test1.png"), 'type' => array("image/png"), 'tmp_name' => array("/tmp/phpmFkEUe"), 'error' => array(0), 'size' => array(9855)));
$errors = array();
$length = count($_FILES['attachments']['name']);
for ($i = 0; $i < $length; $i++) {
    $struct = array('name' => $_FILES['attachments']['name'][$i], 'type' => $_FILES['attachments']['type'][$i], 'tmp_name' => $_FILES['attachments']['tmp_name'][$i], 'error' => $_FILES['attachments']['error'][$i], 'size' => $_FILES['attachments']['size'][$i]);
    $validated = GUMP::is_valid($struct, array('name' => 'required', 'type' => 'required', 'tmp_name' => 'required', 'size' => 'required|numeric'));
    if ($validated !== true) {
        $errors[] = $validated;
    }
}
print_r($errors);
开发者ID:guimafx,项目名称:GUMP,代码行数:14,代码来源:files.php

示例12: array

<?php

include_once 'inc/class.simple_mail.php';
include_once 'inc/gump.class.php';
include_once 'mail-config.php';
// Check Data
$isValid = GUMP::is_valid($_POST, array('first-name' => 'required', 'last-name' => 'required', 'telephone' => 'required', 'email' => 'required', 'message' => 'required'));
if ($isValid === true) {
    // Submit Mail
    $mail = new SimpleMail();
    $mail->setTo(YOUR_EMAIL_ADDRESS, YOUR_COMPANY_NAME)->setSubject('New contact request')->setFrom(htmlspecialchars($_POST['email']), htmlspecialchars($_POST['first-name'] . ' ' . $_POST['last-name']))->addGenericHeader('X-Mailer', 'PHP/' . phpversion())->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')->setMessage(createMessage($_POST))->setWrap(100);
    $mail->send();
    $result = array('result' => 'success', 'msg' => array('Success! Your contact request has been send.'));
    echo json_encode($result);
} else {
    $result = array('result' => 'error', 'msg' => $isValid);
    echo json_encode($result);
}
function createMessage($formData)
{
    $body = "You have got a new contact request from your website : <br><br>";
    $body .= "First Name:  " . htmlspecialchars($formData['first-name']) . " <br><br>";
    $body .= "Last Name:  " . htmlspecialchars($formData['last-name']) . " <br><br>";
    $body .= "Telephone:  " . htmlspecialchars($formData['telephone']) . " <br><br>";
    $body .= "Email:  " . htmlspecialchars($formData['email']) . " <br><br>";
    $body .= "Message: <br><br>";
    $body .= htmlspecialchars($formData['message']);
    return $body;
}
// $mail = new SimpleMail();
// $mail->setTo('mail@themeinjection.com', 'Your Email')
开发者ID:KosDm,项目名称:hydraukr,代码行数:31,代码来源:contact.php

示例13: validate

 /**
  * This function will validate the modal, and return a bool,
  * also, variable $errors will be fetched.
  * @return bool
  */
 public function validate()
 {
     $this->before_validate();
     $validator = new GUMP();
     $validated = $validator->is_valid($this->export(), $this->rules);
     if ($validated === true) {
         //check for addition validate
         $all_good = $this->after_validate();
         if ($all_good == true) {
             return true;
         } else {
             //$this->errors = $all_good;
             return false;
         }
     } else {
         $this->errors = $validated;
         return false;
     }
 }
开发者ID:Artgorae,项目名称:wp-artgorae,代码行数:24,代码来源:ig-model.php

示例14: array

#!/usr/bin/php -q
<?php 
require "../gump.class.php";
$data = array('guid' => "A98C5A1E-A742-4808-96FA-6F409E799937");
$is_valid = GUMP::is_valid($data, array('guid' => 'required|guidv4'));
if ($is_valid === true) {
    // continue
} else {
    print_r($is_valid);
}
开发者ID:guimafx,项目名称:GUMP,代码行数:10,代码来源:guid.php

示例15: isValid

 /**
  * checks to see if a model is valid to save to playbook
  *
  * @return bool
  */
 public function isValid()
 {
     $validations = array_merge($this->validation, $this->__defaultValidation);
     $valid = \GUMP::is_valid($this->props, $validations);
     if ($valid !== true) {
         $this->validationErrors = $valid;
         return false;
     }
     return true;
 }
开发者ID:rubenrangel,项目名称:playbook-hr,代码行数:15,代码来源:Applicant.php


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