• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Validate_Digits类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __construct

 public function __construct($data, $sodu, $tongno)
 {
     $val = new Zend_Validate_NotEmpty();
     $num = new Zend_Validate_Digits();
     $date = new Zend_Validate_Date(array('format' => 'dd/MM/yyyy'));
     if ($val->isValid($data['tenhoadon']) == false) {
         $this->messages[] = "Tên Hóa Đơn không được trống";
     }
     if ($val->isValid($data['tienthanhtoan']) == false) {
         $this->messages[] = "Tiền thanh toán được trống";
     } else {
         if ($num->isValid($data['tienthanhtoan']) == false) {
             $this->messages[] = "Tiền thanh toán phải là số";
         } else {
             if ($data['tienthanhtoan'] > $sodu) {
                 $this->messages[] = "Tiền thanh toán phải nhỏ hơn số dư";
             } else {
                 if ($data['tienthanhtoan'] > $tongno) {
                     $this->messages[] = "Tiền thanh toán không lớn hơn số nợ";
                 } else {
                     if ($data['tienthanhtoan'] < 0) {
                         $this->messages[] = "Tiền thanh toán phải là số dương";
                     }
                 }
             }
         }
     }
     if ($date->isValid($data['ngaythanhtoan']) == false) {
         $this->messages[] = "Ngày thanh toán không đúng";
     }
 }
开发者ID:LongNguyen-51101909,项目名称:Dimopla,代码行数:31,代码来源:hoadon.php


示例2: testIfCustomMessagesOnValidatorInstancesCanBeUsed

 /**
  * @group ZF-11267
  * If we pass in a validator instance that has a preset custom message, this
  * message should be used.
  */
 function testIfCustomMessagesOnValidatorInstancesCanBeUsed()
 {
     // test with a Digits validator
     require_once 'Zend/Validate/Digits.php';
     require_once 'Zend/Validate/NotEmpty.php';
     $data = array('field1' => 'invalid data');
     $customMessage = 'Hey, that\'s not a Digit!!!';
     $validator = new Zend_Validate_Digits();
     $validator->setMessage($customMessage, 'notDigits');
     $this->assertFalse($validator->isValid('foo'), 'standalone validator thinks \'foo\' is a valid digit');
     $messages = $validator->getMessages();
     $this->assertSame($messages['notDigits'], $customMessage, 'stanalone validator does not have custom message');
     $validators = array('field1' => $validator);
     $input = new Zend_Filter_Input(null, $validators, $data);
     $this->assertFalse($input->isValid(), 'invalid input is valid');
     $messages = $input->getMessages();
     $this->assertSame($messages['field1']['notDigits'], $customMessage, 'The custom message is not used');
     // test with a NotEmpty validator
     $data = array('field1' => '');
     $customMessage = 'You should really supply a value...';
     $validator = new Zend_Validate_NotEmpty();
     $validator->setMessage($customMessage, 'isEmpty');
     $this->assertFalse($validator->isValid(''), 'standalone validator thinks \'\' is not empty');
     $messages = $validator->getMessages();
     $this->assertSame($messages['isEmpty'], $customMessage, 'stanalone NotEmpty validator does not have custom message');
     $validators = array('field1' => $validator);
     $input = new Zend_Filter_Input(null, $validators, $data);
     $this->assertFalse($input->isValid(), 'invalid input is valid');
     $messages = $input->getMessages();
     $this->assertSame($messages['field1']['isEmpty'], $customMessage, 'For the NotEmpty validator the custom message is not used');
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:36,代码来源:InputTest.php


示例3: __construct

 public function __construct($data)
 {
     $val = new Zend_Validate_NotEmpty();
     $num = new Zend_Validate_Digits();
     if ($val->isValid($data['ten']) == false) {
         $this->messages[] = "Tên nhà cung cấp không được trống";
     }
     if ($num->isValid($data['sdt']) == false) {
         $this->messages[] = "Số điện thoại phải là số";
     }
     if ($val->isValid($data['sdt']) == false) {
         $this->messages[] = "Số điện thoại không được trống";
     }
     if ($num->isValid($data['fax']) == false) {
         $this->messages[] = "Số fax phải là số";
     }
     if ($val->isValid($data['fax']) == false) {
         $this->messages[] = "Số fax không được trống";
     }
     if (array_key_exists('no', $data)) {
         if ($num->isValid($data['no']) == false) {
             $this->messages[] = "Nợ phải là số";
         }
         if ($val->isValid($data['no']) == false) {
             $this->messages[] = "Nợ không được trống";
         }
     }
 }
开发者ID:LongNguyen-51101909,项目名称:Dimopla,代码行数:28,代码来源:nhacungcap.php


示例4: createForm

 public function createForm($makhohang)
 {
     $this->setDisableLoadDefaultDecorators(true);
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'formmoi/ctpsession.phtml')), 'Form'));
     Zend_Session::start();
     $mysession = new Zend_Session_Namespace('XuLyDonHang');
     $num = new Zend_Validate_Digits();
     if ($mysession->checktp != null) {
         foreach ($mysession->checktp as $item) {
             if ($num->isValid($item)) {
                 $them = $this->createElement('checkbox', '' . $item, array('decorators' => array('ViewHelper')));
                 $them->setAttrib('class', 'checkbox');
                 $this->addElement($them);
             }
         }
     }
     $khohang = $this->createElement('hidden', 'mykhohang', array('decorators' => array('ViewHelper')));
     $khohang->setAttrib('class', 'formEdit')->setValue($makhohang);
     $this->addElement($khohang);
     $giaohang = $this->createElement('submit', 'giaohang', array('decorators' => array('ViewHelper'), 'label' => 'Giao Hàng'));
     $giaohang->setAttrib('class', 'btn btn-primary');
     $this->addElement($giaohang);
     $bochon = $this->createElement('submit', 'bochon', array('decorators' => array('ViewHelper'), 'label' => 'Bỏ Chọn'));
     $bochon->setAttrib('class', 'btn btn-primary');
     $this->addElement($bochon);
 }
开发者ID:LongNguyen-51101909,项目名称:Zend1Example,代码行数:26,代码来源:ctpsession.php


示例5: __construct

 public function __construct($data)
 {
     $val = new Zend_Validate_NotEmpty();
     $num = new Zend_Validate_Digits();
     $date = new Zend_Validate_Date(array('format' => 'dd/MM/yyyy'));
     if ($val->isValid($data['tendonhang']) == false) {
         $this->messages[] = "Tên đơn hàng không được trống";
     }
     if ($date->isValid($data['ngaydathang']) == false) {
         $this->messages[] = "Ngày đặt hàng không đúng";
     }
     if ($val->isValid($data['tiendathang']) == false) {
         $this->messages[] = "Tiền đặt hàng Không được trống";
     }
     if ($num->isValid($data['tiendathang']) == false) {
         $this->messages[] = "Tiền đặt hàng phải là số";
     }
     if ($num->isValid($data['sometvai']) == false) {
         $this->messages[] = "Số mét vải phải là số";
     }
     if ($val->isValid($data['sometvai']) == false) {
         $this->messages[] = "Số mét vải Không được trống";
     }
     if (array_key_exists('makhachhang', $data)) {
         if ($num->isValid($data['makhachhang']) == false) {
             $this->messages[] = "Mã khách hàng phải là số";
         }
         if ($val->isValid($data['makhachhang']) == false) {
             $this->messages[] = "Mã khách hàng không được trống";
         }
     }
 }
开发者ID:LongNguyen-51101909,项目名称:Dimopla,代码行数:32,代码来源:donhang.php


示例6: __construct

 public function __construct($data)
 {
     $val = new Zend_Validate_NotEmpty();
     $num = new Zend_Validate_Digits();
     if ($val->isValid($data['tenloaivai']) == false) {
         $this->messages[] = "Tên loại vải không được trống";
     }
     if ($val->isValid($data['masoi']) == false) {
         $this->messages[] = "Mã sợi không được trống";
     }
     if ($num->isValid($data['masoi']) == false) {
         $this->messages[] = "Mã sợi phải là số";
     }
 }
开发者ID:LongNguyen-51101909,项目名称:Dimopla,代码行数:14,代码来源:loaivai.php


示例7: __construct

 public function __construct($data)
 {
     $val = new Zend_Validate_NotEmpty();
     $num = new Zend_Validate_Digits();
     $date = new Zend_Validate_Date(array('format' => 'dd/MM/yyyy'));
     if ($num->isValid($data['sotansoi']) == false) {
         $this->messages[] = "Số Tấn Sợi phải là số";
     }
     if ($date->isValid($data['ngaymua']) == false) {
         $this->messages[] = "Ngày mua không đúng";
     }
     if ($num->isValid($data['thanhtien']) == false) {
         $this->messages[] = "Thành Tiền phải là số";
     }
 }
开发者ID:LongNguyen-51101909,项目名称:Dimopla,代码行数:15,代码来源:hopdong.php


示例8: getTopicId

 /**
  * STAGE 3:  Choose, create, and optionally update models using business logic.
  * Input data (e.g. via parameters in the URL) can be used to created domain models.
  */
 public function getTopicId()
 {
     if (!$this->topicId) {
         $topic = $this->_request->getParam('topic');
         require_once 'Zend/Validate/Digits.php';
         $validator = new Zend_Validate_Digits();
         // only permit digits using ctype_digit()
         if ($validator->isValid($topic)) {
             if ($topic > 0 && $topic < 99999999) {
                 $this->topicId = $topic;
             }
         }
     }
     return $this->topicId;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:19,代码来源:SubmissionsController.php


示例9: testInvalidValueResultsInProperValidationFailureErrors

 /**
  * @return void
  * @deprecated Since 1.5.0
  */
 public function testInvalidValueResultsInProperValidationFailureErrors()
 {
     $this->assertFalse($this->_validator->isValid('#'));
     $errors = $this->_validator->getErrors();
     $arrayExpected = array(Zend_Validate_Digits::NOT_DIGITS);
     $this->assertThat($errors, $this->identicalTo($arrayExpected));
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:11,代码来源:DigitsTest.php


示例10: __construct

 public function __construct($data)
 {
     $val = new Zend_Validate_NotEmpty();
     $num = new Zend_Validate_Digits();
     if ($val->isValid($data['tenkhohang']) == false) {
         $this->messages[] = "Tên kho hàng không được trống!";
     }
     if ($val->isValid($data['diachi']) == false) {
         $this->messages[] = "Địa chỉ kho hàng không được trống!";
     }
     if ($val->isValid($data['sdt']) == false) {
         $this->messages[] = "Số điện thoại không được trống!";
     }
     if ($num->isValid($data['sdt']) == false) {
         $this->messages[] = "Số điện thoại phải là số";
     }
 }
开发者ID:LongNguyen-51101909,项目名称:Dimopla,代码行数:17,代码来源:khohang.php


示例11: __construct

 public function __construct($data)
 {
     $val = new Zend_Validate_NotEmpty();
     $num = new Zend_Validate_Digits();
     //  $kh = new Model_Khachhang();
     if ($val->isValid($data['TenCTP']) == false) {
         $this->messages[] = "Cây thành phẩm không được trống";
     }
     if ($num->isValid($data['sometvai']) == false) {
         $this->messages[] = "Số mét vải phải là số";
     }
     if (array_key_exists('loaivai', $data)) {
         if ($val->isValid($data['loaivai']) == false) {
             $this->messages[] = "Vui lòng điền loại vải!";
         }
     }
 }
开发者ID:LongNguyen-51101909,项目名称:Dimopla,代码行数:17,代码来源:caythanhpham.php


示例12: __construct

 public function __construct()
 {
     // Validators --------------------------
     $notEmpty = new Zend_Validate_NotEmpty(array(true));
     $notEmpty->setMessage($this->_errorMessages['isEmpy']);
     $digits = new Zend_Validate_Digits();
     $digits->setMessage($this->_errorMessages['digits']);
     $emailValidator = new Zend_Validate_EmailAddress();
     $emailValidator->setMessage($this->_errorMessages['emailValidator']);
     $foneValidator = new Zend_Validate_StringLength();
     $foneValidator->setMin(8);
     $foneValidator->setMessage($this->_errorMessages['foneValidator']);
     //--------------------------------------
     $nome = new Zend_Form_Element_Text('nome');
     $nome->setAttrib('class', 'form-control');
     $nome->setRequired(true);
     $nome->addValidator($notEmpty, true);
     //--------------------------------------------------------
     $fone = new Zend_Form_Element_Text('fone');
     $fone->setAttrib('class', 'form-control');
     $fone->setRequired(true);
     $fone->addValidator($notEmpty, true);
     $fone->addValidator($digits, true);
     $fone->addValidator($foneValidator, true);
     //--------------------------------------------------------
     $email = new Zend_Form_Element_Text('email');
     $email->setAttrib('class', 'form-control');
     $email->setRequired(true);
     $email->addValidator($notEmpty, true);
     $email->addValidator($emailValidator, true);
     //--------------------------------------------------------
     $mensagem = new Zend_Form_Element_Textarea('mensagem');
     $mensagem->setAttrib('class', 'form-control');
     $mensagem->setAttrib('cols', 30);
     $mensagem->setAttrib('rows', 10);
     $mensagem->setRequired(true);
     $mensagem->addValidator($notEmpty, true);
     //--------------------------------------------------------
     $this->addElement($nome);
     $this->addElement($fone);
     $this->addElement($email);
     $this->addElement($mensagem);
     $this->setElementDecorators(array('ViewHelper', 'Errors'));
 }
开发者ID:elvisdandrea,项目名称:esselence,代码行数:44,代码来源:FaleConoscoForm.php


示例13: init

 /**
  * Inicializace formulare
  *
  */
 public function init()
 {
     $this->setMethod(self::METHOD_POST);
     //nazev testu
     $name = $this->createElement('text', 'nazev');
     $name->addFilter('StringTrim');
     $name->setRequired(true);
     $name->setAttrib('class', 'form-control dd-test');
     $name->setAttrib('placeholder', 'Name');
     $name->removeDecorator('Label');
     $this->addElement($name);
     //kategorie testu
     $technology = new Zend_Form_Element_Select('id_technologie');
     $technology->removeDecorator('Label');
     $technology->setAttrib('class', 'form-control dd-test');
     $this->addElement($technology);
     //obtiznost
     $seniority = new Zend_Form_Element_Select('id_seniorita');
     $seniority->removeDecorator('Label');
     $seniority->setAttrib('class', 'form-control dd-test');
     $this->addElement($seniority);
     //prideleny cas
     $time = $this->createElement('text', 'pocet_minut');
     $time->setRequired(true);
     $validator = new Zend_Validate_Digits();
     $validator->isValid("1234567890");
     $time->addValidator($validator);
     $time->setAttrib('class', 'form-control dd-test');
     $time->setAttrib('placeholder', 'Allotted time');
     $time->removeDecorator('Label');
     $this->addElement($time);
     //popis
     $name = $this->createElement('textarea', 'popis');
     $name->addFilter('StringTrim');
     $name->setRequired(true);
     $name->setAttrib('class', 'form-control dd-test');
     $name->setAttrib('placeholder', 'Description');
     $name->removeDecorator('Label');
     $this->addElement($name);
     //submit button
     $button = $this->createElement('submit', 'saveTest', array('label' => 'Save General Information'));
     $button->setAttrib('class', 'extra-button-own');
     $this->addElement($button);
 }
开发者ID:cngroupdk,项目名称:InterviewMe_Tym1,代码行数:48,代码来源:TestForm.php


示例14: __construct

 public function __construct($data, $sotan)
 {
     $val = new Zend_Validate_NotEmpty();
     $num = new Zend_Validate_Digits();
     //  $kh = new Model_Khachhang();
     if ($val->isValid($data['sokgsoi']) == false) {
         $this->messages[] = "Số kg sợi phải không được trống";
     } else {
         if ($num->isValid($data['sokgsoi']) == false) {
             $this->messages[] = "Số kg sợi phải là số";
         } else {
             if ($data['sokgsoi'] > $sotan * 1000) {
                 $this->messages[] = "Trong kho chỉ còn " . $sotan * 1000 . " kg sợi.";
             }
         }
     }
     if ($val->isValid($data['sometvai']) == false) {
         $this->messages[] = "Số mét vải không được trống";
     } else {
         if ($num->isValid($data['sometvai']) == false) {
             $this->messages[] = "Số mét vải phải là số";
         }
     }
 }
开发者ID:LongNguyen-51101909,项目名称:Dimopla,代码行数:24,代码来源:caymoc.php


示例15: Zend_Session_Namespace

<?php

use Zend\Http\Client;
echo $this->headMeta();
echo $this->headLink();
echo $this->headScript();
Zend_Session::start();
$mysession = new Zend_Session_Namespace('Zend_Auth');
$router = Zend_Controller_Front::getInstance()->getRouter();
$num = new Zend_Validate_Digits();
$data = new My_Data();
$caymoc = new Model_Caymoc();
$loaivai = new Model_Loaivai();
//     echo "<pre>";
//     print_r($mysession->checked);
//     echo "</pre>";
$form = new Form_Formmoi_Xemkhomoc();
$formchon = new Form_Formmoi_Khomoc();
$makho = $this->param->getParam("mykhohang");
if ($this->param->isPost()) {
    $param = $this->param->getPost();
    //         echo "<pre>";
    //         print_r($param);
    //         echo "</pre>";
    // truong hop bo chon session
    if ($mysession->checked != null && array_key_exists("bochon", $param)) {
        foreach ($param as $key => $item) {
            if ($item == 1 && $num->isValid($key) && in_array($key, $mysession->checked)) {
                foreach ($mysession->checked as $skey => $sitem) {
                    if ($sitem == $key) {
                        unset($mysession->checked[$skey]);
开发者ID:LongNguyen-51101909,项目名称:Zend1Example,代码行数:31,代码来源:chonmoc.php


示例16: _validateInputRule

 /**
  * Validate value by attribute input validation rule
  *
  * @param string $value
  * @return array|true
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _validateInputRule($value)
 {
     // skip validate empty value
     if (empty($value)) {
         return true;
     }
     $label = $this->getAttribute()->getStoreLabel();
     $validateRules = $this->getAttribute()->getValidationRules();
     $inputValidation = ArrayObjectSearch::getArrayElementByName($validateRules, 'input_validation');
     if (!is_null($inputValidation)) {
         switch ($inputValidation) {
             case 'alphanumeric':
                 $validator = new \Zend_Validate_Alnum(true);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alnum::INVALID);
                 $validator->setMessage(__('"%1" contains non-alphabetic or non-numeric characters.', $label), \Zend_Validate_Alnum::NOT_ALNUM);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Alnum::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'numeric':
                 $validator = new \Zend_Validate_Digits();
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Digits::INVALID);
                 $validator->setMessage(__('"%1" contains non-numeric characters.', $label), \Zend_Validate_Digits::NOT_DIGITS);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Digits::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'alpha':
                 $validator = new \Zend_Validate_Alpha(true);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alpha::INVALID);
                 $validator->setMessage(__('"%1" contains non-alphabetic characters.', $label), \Zend_Validate_Alpha::NOT_ALPHA);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Alpha::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'email':
                 /**
                 __("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded")
                 __("Invalid type given. String expected")
                 __("'%value%' appears to be a DNS hostname but contains a dash in an invalid position")
                 __("'%value%' does not match the expected structure for a DNS hostname")
                 __("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'")
                 __("'%value%' does not appear to be a valid local network name")
                 __("'%value%' does not appear to be a valid URI hostname")
                 __("'%value%' appears to be an IP address, but IP addresses are not allowed")
                 __("'%value%' appears to be a local network name but local network names are not allowed")
                 __("'%value%' appears to be a DNS hostname but cannot extract TLD part")
                 __("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
                 */
                 $validator = new \Zend_Validate_EmailAddress();
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_EmailAddress::INVALID);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::INVALID_FORMAT);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_HOSTNAME);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::DOT_ATOM);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::QUOTED_STRING);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
                 $validator->setMessage(__('"%1" uses too many characters.', $label), \Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
                 $validator->setMessage(__("'%value%' looks like an IP address, which is not an acceptable format."), \Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."), \Zend_Validate_Hostname::UNKNOWN_TLD);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but contains a dash in an invalid position."), \Zend_Validate_Hostname::INVALID_DASH);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but we cannot match it against the hostname schema for TLD '%tld%'."), \Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but cannot extract TLD part."), \Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
                 $validator->setMessage(__("'%value%' does not look like a valid local network name."), \Zend_Validate_Hostname::INVALID_LOCAL_NAME);
                 $validator->setMessage(__("'%value%' looks like a local network name, which is not an acceptable format."), \Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
                 $validator->setMessage(__("'%value%' appears to be a DNS hostname, but the given punycode notation cannot be decoded."), \Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
             case 'url':
                 $parsedUrl = parse_url($value);
                 if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
                     return [__('"%1" is not a valid URL.', $label)];
                 }
                 $validator = new \Zend_Validate_Hostname();
                 if (!$validator->isValid($parsedUrl['host'])) {
                     return [__('"%1" is not a valid URL.', $label)];
                 }
                 break;
             case 'date':
                 $validator = new \Zend_Validate_Date(\Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Date::INVALID);
                 $validator->setMessage(__('"%1" is not a valid date.', $label), \Zend_Validate_Date::INVALID_DATE);
                 $validator->setMessage(__('"%1" does not fit the entered date format.', $label), \Zend_Validate_Date::FALSEFORMAT);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
//.........这里部分代码省略.........
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:101,代码来源:AbstractData.php


示例17: _validateInputRule

 /**
  * Validate value by attribute input validation rule
  *
  * @param string $value
  * @return string
  */
 protected function _validateInputRule($value)
 {
     // skip validate empty value
     if (empty($value)) {
         return true;
     }
     $label = Mage::helper('customer')->__($this->getAttribute()->getStoreLabel());
     $validateRules = $this->getAttribute()->getValidateRules();
     if (!empty($validateRules['input_validation'])) {
         switch ($validateRules['input_validation']) {
             case 'alphanumeric':
                 $validator = new Zend_Validate_Alnum(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alnum::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic and digit characters.', $label), Zend_Validate_Alnum::NOT_ALNUM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alnum::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'numeric':
                 $validator = new Zend_Validate_Digits();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Digits::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" contains not only digit characters.', $label), Zend_Validate_Digits::NOT_DIGITS);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Digits::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'alpha':
                 $validator = new Zend_Validate_Alpha(true);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Alpha::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" has not only alphabetic characters.', $label), Zend_Validate_Alpha::NOT_ALPHA);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is an empty string.', $label), Zend_Validate_Alpha::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'email':
                 /**
                 $this->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded")
                 $this->__("Invalid type given. String expected")
                 $this->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position")
                 $this->__("'%value%' does not match the expected structure for a DNS hostname")
                 $this->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'")
                 $this->__("'%value%' does not appear to be a valid local network name")
                 $this->__("'%value%' does not appear to be a valid URI hostname")
                 $this->__("'%value%' appears to be an IP address, but IP addresses are not allowed")
                 $this->__("'%value%' appears to be a local network name but local network names are not allowed")
                 $this->__("'%value%' appears to be a DNS hostname but cannot extract TLD part")
                 $this->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
                 */
                 $validator = new Zend_Validate_EmailAddress();
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_EmailAddress::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_FORMAT);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_HOSTNAME);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid hostname.', $label), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::DOT_ATOM);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::QUOTED_STRING);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid email address.', $label), Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" exceeds the allowed length.', $label), Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be an IP address, but IP addresses are not allowed"), Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list"), Zend_Validate_Hostname::UNKNOWN_TLD);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position"), Zend_Validate_Hostname::INVALID_DASH);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'"), Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot extract TLD part"), Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' does not appear to be a valid local network name"), Zend_Validate_Hostname::INVALID_LOCAL_NAME);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a local network name but local network names are not allowed"), Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
                 $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded"), Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
             case 'url':
                 $parsedUrl = parse_url($value);
                 if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 $validator = new Zend_Validate_Hostname();
                 if (!$validator->isValid($parsedUrl['host'])) {
                     return array(Mage::helper('customer')->__('"%s" is not a valid URL.', $label));
                 }
                 break;
             case 'date':
                 $validator = new Zend_Validate_Date(Varien_Date::DATE_INTERNAL_FORMAT);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" invalid type entered.', $label), Zend_Validate_Date::INVALID);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" is not a valid date.', $label), Zend_Validate_Date::INVALID_DATE);
                 $validator->setMessage(Mage::helper('customer')->__('"%s" does not fit the entered date format.', $label), Zend_Validate_Date::FALSEFORMAT);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
         }
     }
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:101,代码来源:Abstract.php


示例18: getValidator

 /**
  * returns an validator for a single category
  *
  * @return Zend_Filter_Input validator
  */
 protected function getValidator()
 {
     // define filter
     $filterTrim = new Zend_Filter_StringTrim();
     $filterUtf8 = new application_filter_utf8();
     $filter = array('id' => $filterTrim, 'name' => array($filterTrim, $filterUtf8), 'position' => $filterTrim);
     // define validators
     $validatorId = new application_validate_categoryid();
     $validatorId->setMessage(Zend_Registry::get('language')->translate("category doesn't exists"), application_validate_categoryid::NOT_EXISTS);
     $validatorNotEmpty = new Zend_Validate_NotEmpty();
     $validatorNotEmpty->setMessage(Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Validate_NotEmpty::IS_EMPTY);
     $validatorAlnum = new Zend_Validate_Alnum(true);
     $validatorAlnum->setMessage(Zend_Registry::get('language')->translate('Only alphanummeric values allowed'), Zend_Validate_Alnum::NOT_ALNUM);
     $validatorAlnum->setMessage(Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Validate_Alnum::STRING_EMPTY);
     $validatorNum = new Zend_Validate_Digits(false);
     $validatorNum->setMessage(Zend_Registry::get('language')->translate('Only digits allowed'), Zend_Validate_Digits::NOT_DIGITS);
     $validatorNum->setMessage(Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Validate_Digits::STRING_EMPTY);
     $validators = array('id' => array($validatorId, Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'name' => array($validatorNotEmpty, Zend_Filter_Input::ALLOW_EMPTY => false, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED), 'position' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL));
     // create validation main object
     $validator = new Zend_Filter_Input($filter, $validators, array(), array(Zend_Filter_Input::NOT_EMPTY_MESSAGE => Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Filter_Input::BREAK_CHAIN => false));
     // return filter input object
     return $validator;
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:28,代码来源:categories.php


示例19: array

     }
 } else {
     $socaymoc = $param["soluong"];
     $mavai = $param["mavai"];
     $sotansoi = $param["sotan"];
     $tongsomet = $param["tongsomet"];
     $khomoc = $param["khomoc"];
     $thongso = array('sotansoi' => $sotansoi, 'mavai' => $mavai, 'socaymoc' => $socaymoc, 'tongsometvai' => $tongsomet, 'khomoc' => $khomoc);
     $form->populate($thongso);
     echo $form;
     $formmoc->createCayMoc($socaymoc, $mavai, $sotansoi, $tongsomet, $khomoc);
     $data = new My_Data();
     $valid = $data->isValidCaymoc($param);
     $change = false;
     $malo = $caymoc->getMaxMaLo() + 1;
     $num = new Zend_Validate_Digits();
     if (!is_array($valid)) {
         foreach ($param as $key => $item) {
             if ($num->isValid($key)) {
                 $change = true;
                 $data = array("MaMoc" => null, "MaVai" => $ma 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Validate_EmailAddress类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Validate_Date类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap