本文整理汇总了PHP中Zend_Validate_StringLength::setMin方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_StringLength::setMin方法的具体用法?PHP Zend_Validate_StringLength::setMin怎么用?PHP Zend_Validate_StringLength::setMin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_StringLength
的用法示例。
在下文中一共展示了Zend_Validate_StringLength::setMin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Overrides init() in Zend_Form
*
* @access public
* @return void
*/
public function init()
{
// init the parent
parent::init();
// set the form's method
$this->setMethod('post');
$user = Zend_Auth::getInstance()->getIdentity();
$oldPasswordValidator = new App_Validate_PasswordExists(array('table' => 'backoffice_users', 'field' => 'password', 'treatment' => 'BackofficeUser::hashPassword', 'userPkValue' => $user->id));
$complexityValidator = new Zend_Validate_Regex('/^(?=.*\\d)(?=.*[a-z|A-Z]).{7,}$/');
$complexityValidator->setMessage('The selected password does not meet the required complexity requirements');
$stringLengthValidator = new Zend_Validate_StringLength();
$stringLengthValidator->setMin(7);
$stringLengthValidator->setMessage('Your password must be at least 7 characters long');
$passwordHistoryValidator = new App_Validate_NoPasswordExists(array('table' => 'password_log', 'field' => 'password', 'treatment' => 'BackofficeUser::hashPassword', 'userPkField' => 'user_id', 'userPkValue' => $user->id));
$oldPassword = new Zend_Form_Element_Password('old_password');
$oldPassword->setOptions(array('label' => $this->t('Old password'), 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $oldPasswordValidator)));
$this->addElement($oldPassword);
$password = new Zend_Form_Element_Password('password');
$password->setOptions(array('label' => $this->t('New password'), 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $stringLengthValidator, $complexityValidator, $passwordHistoryValidator)));
$this->addElement($password);
$sameAsValidator = new App_Validate_SameAs($password);
$sameAsValidator->setMessage('The two passwords do not coincide.', App_Validate_SameAs::NOT_THE_SAME);
$retypeNewPassword = new Zend_Form_Element_Password('retype_new_password');
$retypeNewPassword->setOptions(array('label' => $this->t('Retype new password'), 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $sameAsValidator)));
$this->addElement($retypeNewPassword);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setOptions(array('label' => $this->t('Save password'), 'required' => TRUE));
$this->addElement($submit);
}
示例2: init
public function init($cid)
{
global $mySession;
$db = new Db();
$full_name_value = "";
$phone_value = "";
$email_value = "";
$comment_value = "";
$captcha_value = "";
$subject_value = "";
if ($cid != "") {
$adminData = $db->runQuery("select * from " . user . " where id='" . $cid . "'");
$full_name_value = $adminData[0]['fname'] . " " . $adminData[0]['lname'];
$phone_value = $adminData[0]['phone'];
$email_value = $adminData[0]['email'];
$comment_value = $adminData[0]['comment'];
}
$full_name = new Zend_Form_Element_Text('full_name');
$full_name->setRequired(true)->addValidator('NotEmpty', true, array('messages' => "Please enter Full Name"))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setValue($full_name_value);
/*$phone = new Zend_Form_Element_Text('phone');
$phone->setRequired(true)
->addValidator('NotEmpty',true,array('messages' =>"Please enter phone number"))
->addDecorator('Errors', array('class'=>'error'))
->setAttrib("onkeypress","return checknummsp(event);")
->setAttrib("class","mws-textinput required")
->addValidator('Digits',true,array('messages' =>"enter proper phone number"))
->setValue($phone_value);*/
if (isset($_REQUEST['phone'])) {
$stringLength = new Zend_Validate_StringLength($_POST['phone']);
$stringLength->setMin(10);
$stringLength->setMax(10);
$phone->addValidator($stringLength);
}
$email_address = new Zend_Form_Element_Text('email_address');
$email_address->setRequired(true)->addValidator('NotEmpty', true, array('messages' => "enter email address"))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required email")->setValue($email_value);
$cemail_address = new Zend_Form_Element_Text('cemail_address');
$cemail_address->setRequired(true)->addValidator('NotEmpty', true, array('messages' => "enter email address"))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required email")->setAttrib("equalTo", "#email_address")->setValue($email_value);
$subject = new Zend_Form_Element_Text('subject');
$subject->setRequired(true)->addValidator('NotEmpty', true, array('messages' => "enter email address"))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setValue($subject_value);
/* $comment= new Zend_Form_Element_Textarea('comment');
$comment->setRequired(true)
->addDecorator('Errors', array('class'=>'error'))
->setAttrib("class","required")
->setAttrib("rows","4")
->setAttrib("cols","30")
->addValidator('NotEmpty',true,array('messages' =>"Enter message"));*/
$enquiry = new Zend_Form_Element_Textarea('enquiry');
$enquiry->setRequired(true)->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "required")->setAttrib("rows", "4")->setAttrib("cols", "30")->addValidator('NotEmpty', true, array('messages' => "Enter message"));
/*$captcha = new Zend_Form_Element_Text('captcha');
$captcha->setRequired(true)
->addDecorator('Errors', array('class'=>'error'))
->setAttrib("class","mws-textinput required")
->addValidator('NotEmpty',true,array('messages' =>"Enter captcha"));*/
/*$check = new Zend_Form_Element_Hidden('check');
$check->setRequired(true)
->setValue($text);*/
$this->addElements(array($full_name, $email_address, $cemail_address, $subject, $enquiry));
}
示例3: _getPasswordElement
private function _getPasswordElement()
{
$passwordLengthValidator = new Zend_Validate_StringLength();
$passwordLengthValidator->setMin(4)->setMax(20);
$passwordElement = new Zend_Form_Element_Password('Password');
$passwordElement->setRequired()->setLabel('Password')->addValidator($passwordLengthValidator);
return $passwordElement;
}
示例4: overrideStringLengthValidator
public static function overrideStringLengthValidator($p_min, $p_max)
{
$validator = new Zend_Validate_StringLength();
$validator->setMin($p_min);
$validator->setMax($p_max);
$validator->setMessage(_("'%value%' is less than %min% characters long"), Zend_Validate_StringLength::TOO_SHORT);
$validator->setMessage(_("'%value%' is more than %max% characters long"), Zend_Validate_StringLength::TOO_LONG);
return $validator;
}
示例5: testSetMaxExceptionLessThanMin
/**
* Ensures that setMax() throws an exception when given a value less than the minimum
*
* @return void
*/
public function testSetMaxExceptionLessThanMin()
{
$max = 1;
$min = 2;
try {
$this->_validator->setMin($min)->setMax($max);
$this->fail('Expected Zend_Validate_Exception not thrown');
} catch (Zend_Validate_Exception $e) {
$this->assertEquals("The maximum must be greater than or equal to the minimum length, but {$max} < {$min}", $e->getMessage());
}
}
示例6: _validateUrl
protected function _validateUrl()
{
$val = new Zend_Validate_StringLength();
$val->setMin(1);
$val->setMax(255);
$val->setMessage('Dit is verplicht in te vullen', Zend_Validate_StringLength::TOO_SHORT);
$val->setMessage('Oops dit is te lang', Zend_Validate_StringLength::TOO_LONG);
if ($val->isValid($this->_agenda->getUrl())) {
return true;
}
$msg = Sanmax_MessageStack::getInstance('SxModule_Doctor_Agenda');
$msg->addMessage('url', $validator->getMessages());
return false;
}
示例7: insertEventsRows
public function insertEventsRows($text, $id, $array)
{
if ($this->conn->checkAdmin()) {
$validator = new Zend_Validate_StringLength(1, 100);
$int = new Zend_Validate_Int();
if (!$validator->isValid($text)) {
return $this->test;
}
$num = sizeof($array);
if (!$int->isValid($num)) {
return $this->test;
}
if (2 > $num) {
return $this->test;
}
if (!$int->isValid($id)) {
return $this->test;
}
$query = "CALL insertEvent('" . $text . "','" . $id . "')";
$idEvent = $this->conn->result($query);
if (!is_array($idEvent)) {
return $idEvent;
}
$validator->setMax(100);
$validator->setMin(0);
$query2 = " ";
for ($i = 0; $i < $num; $i++) {
if (!$validator->isValid($array[$i])) {
return $this->test;
}
if ($array[$i] == "") {
$type = 'null';
} else {
$type = "'" . $array[$i] . "'";
}
$query2 .= "call insertEventType({$type},'" . $idEvent[0]["number"] . "');";
}
if ($query2 != " ") {
$this->conn->multiinsert($query2);
}
$query = "CALL selectEvents('" . $id . "')";
return $this->conn->result($query);
} else {
$this->test->type = "error";
$this->test->info = "nologin";
return $this->test;
}
}
示例8: init
public function init()
{
$oTradutor = $this->getTranslator();
$oBaseUrlHelper = new Zend_View_Helper_BaseUrl();
$this->setName('formLiberacaoUsuario');
$this->setAction($oBaseUrlHelper->baseUrl('/default/cadastro-eventual/confirmar'));
$this->setMethod('post');
$oElm = $this->createElement('text', 'hash', array('divspan' => 9));
$oElm->setLabel('Código Verificação:');
$oElm->setAttrib('class', 'span7');
$oElm->setRequired(TRUE);
$oElm->removeDecorator('errors');
$this->addElement($oElm);
$oElm = $this->createElement('text', 'cnpjcpf', array('divspan' => 9));
$oElm->setLabel('CPF / CNPJ:');
$oElm->setAttrib('class', 'span3 mask-cpf-cnpj');
$oElm->setAttrib('maxlength', 18);
$oElm->addValidator(new DBSeller_Validator_CpfCnpj());
$oElm->addFilter(new Zend_Filter_Digits());
$oElm->setRequired(TRUE);
$oElm->removeDecorator('errors');
$this->addElement($oElm);
$oValidaTamanhoCampo = new Zend_Validate_StringLength();
$oValidaTamanhoCampo->setMin('6');
$sMensagemValidacao = $oTradutor->_(sprintf('Os campos "<b>Senha</b>" e "<b>Confirme a Senha</b>" devem possuir no mínimo %s caracteres.', $oValidaTamanhoCampo->getMin()));
$oElm = $this->createElement('password', 'senha', array('divspan' => 9));
$oElm->setLabel('Senha:');
$oElm->setAttrib('minlength', $oValidaTamanhoCampo->getMin());
$oElm->addValidator(new Zend_Validate_Identical('senharepetida'));
$oElm->setAttrib('message-error', $sMensagemValidacao);
$oElm->setAttrib('class', 'span3');
$oElm->setRequired(TRUE);
$oElm->addValidator($oValidaTamanhoCampo);
$oElm->removeDecorator('errors');
$this->addElement($oElm);
$oElm = $this->createElement('password', 'senharepetida', array('divspan' => 10));
$oElm->setLabel('Confirme a Senha:');
$oElm->setAttrib('class', 'span3');
$oElm->setAttrib('minlength', $oValidaTamanhoCampo->getMin());
$oElm->addValidator(new Zend_Validate_Identical('senha'));
$oElm->addValidator($oValidaTamanhoCampo);
$oElm->setRequired(TRUE);
$oElm->removeDecorator('errors');
$this->addElement($oElm);
$this->addDisplayGroup(array('hash', 'cnpjcpf', 'senha', 'senharepetida'), 'dados_liberacao', array('legend' => 'Confirme seu Cadastro'));
$this->addElement('submit', 'confirmar', array('label' => 'Confirmar', 'style' => 'margin-left:30px', 'buttonType' => Twitter_Bootstrap_Form_Element_Submit::BUTTON_PRIMARY));
}
示例9: init
public function init()
{
$oBaseUrlHelper = new Zend_View_Helper_BaseUrl();
$this->setName('formRecuperarSenha');
$this->setAction($oBaseUrlHelper->baseUrl('/auth/login/recuperar-senha-post'));
$this->setMethod('post');
$oElm = $this->createElement('text', 'hash', array('divspan' => 9));
$oElm->setLabel('Código Verificação:');
$oElm->setAttrib('class', 'span7');
$oElm->setRequired(TRUE);
$oElm->removeDecorator('errors');
$this->addElement($oElm);
$oElm = $this->createElement('text', 'email', array('divspan' => 9));
$oElm->setLabel('Email:');
$oElm->setAttrib('class', 'span7');
$oElm->setAttrib('maxlength', 100);
$oElm->addValidator(new Zend_Validate_EmailAddress());
$oElm->setRequired(TRUE);
$oElm->removeDecorator('errors');
$this->addElement($oElm);
$oValidaTamanhoCampo = new Zend_Validate_StringLength();
$oValidaTamanhoCampo->setMin('6');
$sMensagemValidacao = 'Os campos "<b>Senha</b>" e "<b>Confirme a Senha</b>" devem ser maiores de ';
$sMensagemValidacao .= " {$oValidaTamanhoCampo->getMin()} caracteres.";
$oElm = $this->createElement('password', 'senha', array('divspan' => 9));
$oElm->setLabel('Senha:');
$oElm->addValidator(new Zend_Validate_Identical('senharepetida'));
$oElm->setAttrib('message-error', $sMensagemValidacao);
$oElm->setAttrib('class', 'span3');
$oElm->setAttrib('minlength', $oValidaTamanhoCampo->getMin());
$oElm->setRequired(TRUE);
$oElm->addValidator($oValidaTamanhoCampo);
$oElm->removeDecorator('errors');
$this->addElement($oElm);
$oElm = $this->createElement('password', 'senharepetida', array('divspan' => 9));
$oElm->setLabel('Confirme a Senha:');
$oElm->setAttrib('class', 'span3');
$oElm->setAttrib('minlength', $oValidaTamanhoCampo->getMin());
$oElm->addValidator(new Zend_Validate_Identical('senha'));
$oElm->addValidator($oValidaTamanhoCampo);
$oElm->setRequired(TRUE);
$oElm->removeDecorator('errors');
$this->addElement($oElm);
$this->addDisplayGroup(array('hash', 'email', 'senha', 'senharepetida'), 'dados_liberacao', array('legend' => 'Recuperação de Senha'));
$this->addElement('submit', 'confirmar', array('label' => 'Confirmar', 'class' => 'span2', 'style' => 'margin-left:30px', 'buttonType' => Twitter_Bootstrap_Form_Element_Submit::BUTTON_PRIMARY));
}
示例10: __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'));
}
示例11: setSettings
public function setSettings($nImageId, $sUserName, $sDescr)
{
if (is_numeric($nImageId)) {
$aImageSettings = array();
$oStringLenght = new Zend_Validate_StringLength();
$oStringLenght->setMin(0);
$oStringLenght->setMax(50);
if ($oStringLenght->isValid($sUserName)) {
$aImageSettings["user_name"] = $sUserName;
}
$oStringLenght->setMax(100);
if ($oStringLenght->isValid($sDescr)) {
$aImageSettings["descr"] = $sDescr;
}
$oModelImage = new Admin_Model_Image();
if ($oModelImage->saveSettings($nImageId, $aImageSettings)) {
return true;
}
}
return null;
}
示例12: init
public function init()
{
$this->setMethod('post')->setAttrib('id', 'frmFabricante');
// Elemento: Nombre
$e = new Zend_Form_Element_Text('nombre');
$e->setLabel('Nombre');
$e->setAttrib('maxlength', '50');
$e->setRequired(true);
$v = new Zend_Validate_StringLength(array('min' => 5, 'max' => 50));
$v->setMessage("'%value%' debe tener más de %min% characters.", Zend_Validate_StringLength::TOO_SHORT);
$e->addValidator($v);
$this->addElement($e);
// Elemento: RUC
$e = new Zend_Form_Element_Text('ruc');
$e->setLabel('RUC');
$e->setRequired(true);
$e->addValidator(new Zend_Validate_Digits());
$v = new Zend_Validate_StringLength();
$v->setMin(11)->setMax(11);
$e->addValidator($v);
$e->setAttrib('maxlength', '11');
$this->addElement($e);
$this->addElement('submit', 'Enviar');
}
示例13: setLength
/**
* Set length
*
* @param $length
* @return Mage_Oauth_Model_Consumer_Validator_KeyLength
*/
public function setLength($length)
{
parent::setMax($length);
parent::setMin($length);
return $this;
}
示例14: __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']);
$dddValidator = new Zend_Validate_StringLength();
$dddValidator->setMin(2);
$dddValidator->setMessage($this->_errorMessages['foneValidator']);
//--------------------------------------
$nome = new Zend_Form_Element_Text('nome');
$nome->setAttrib('class', 'form-control');
$nome->setAttrib('required', true);
$nome->setAttrib('accesskey', 'n');
$nome->setRequired(true);
$nome->addValidator($notEmpty, true);
//--------------------------------------------------------
$fone = new Zend_Form_Element_Text('fone');
$fone->setAttrib('class', 'form-control fone-input');
$fone->setAttrib('required', true);
$fone->setAttrib('accesskey', 'f');
$fone->setRequired(true);
$fone->addValidator($notEmpty, true);
$fone->addValidator($digits, true);
$fone->addValidator($foneValidator, true);
//--------------------------------------------------------
$cidade = new Zend_Form_Element_Text('cidade');
$cidade->setAttrib('class', 'form-control');
$cidade->setAttrib('required', false);
$cidade->setAttrib('accesskey', 'c');
$cidade->setRequired(false);
//--------------------------------------------------------
$ddd = new Zend_Form_Element_Text('ddd');
$ddd->setAttrib('class', 'form-control');
$ddd->setAttrib('required', true);
$ddd->setAttrib('accesskey', 'd');
$ddd->setRequired(true);
$ddd->addValidator($notEmpty, true);
$ddd->addValidator($digits, true);
$ddd->addValidator($dddValidator, true);
//--------------------------------------------------------
$email = new Zend_Form_Element_Text('email');
$email->setAttrib('class', 'form-control');
$email->setAttrib('required', true);
$email->setAttrib('accesskey', 'e');
$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('required', true);
$mensagem->setAttrib('accesskey', 'm');
$mensagem->setAttrib('cols', 1);
$mensagem->setAttrib('rows', 1);
$mensagem->setRequired(true);
$mensagem->addValidator($notEmpty, true);
//--------------------------------------------------------
$imovel = new Zend_Form_Element_Text('imovel');
$imovel->setAttrib('class', 'form-control');
$imovel->setAttrib('accesskey', 'i');
$imovel->setAttrib('cols', 1);
$imovel->setAttrib('rows', 1);
$imovel->setRequired(false);
//--------------------------------------------------
$this->addElement($nome);
$this->addElement($fone);
$this->addElement($ddd);
$this->addElement($email);
$this->addElement($cidade);
$this->addElement($mensagem);
$this->addElement($imovel);
$this->setElementDecorators(array('ViewHelper', 'Errors'));
}
示例15: minimalValidate
private function minimalValidate($value, $setting)
{
if (isset($setting["length"])) {
$length = $setting["length"];
$validator = new Zend_Validate_StringLength();
$validator->setMin($min);
return !$validator->isValid($value);
} else {
return false;
}
}