本文整理汇总了PHP中Zend_Validate_StringLength类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_StringLength类的具体用法?PHP Zend_Validate_StringLength怎么用?PHP Zend_Validate_StringLength使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Validate_StringLength类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:omusico,项目名称:logica,代码行数:35,代码来源:ChangePasswordForm.php
示例2: _createStringLengthValidator
protected function _createStringLengthValidator($minValue, $maxValue, $minMessage, $maxMessage)
{
$stringLengthValidator = new Zend_Validate_StringLength(array('min' => $minValue, 'max' => $maxValue));
$stringLengthValidator->setMessage($minMessage, Zend_Validate_StringLength::TOO_SHORT);
$stringLengthValidator->setMessage($maxMessage, Zend_Validate_StringLength::TOO_LONG);
return $stringLengthValidator;
}
开发者ID:rizkioa,项目名称:etak6,代码行数:7,代码来源:Form.php
示例3: _isValid
/**
* @param array $value
* @return boolean indicating is any valid data of interest was passed
*/
protected function _isValid($value)
{
$partialHappened = false;
$isPost = 'post' == $this->getMethodContext();
// comment is set optional for put, required for post
if (isset($value['comment'])) {
$partialHappened = true;
$validate = new Zend_Validate_StringLength(array(1, 1000));
if (!$validate->isValid($value['comment'])) {
$this->_addValidateMessagesAndErrors($validate);
}
} elseif ($isPost) {
$this->_error(self::COMMENT_REQUIRED);
}
// creator_user_id required for post
// creator can't be changed for put, so if not post, then don't bother
// checking this, it will be ignored later
if (isset($value['creator_user_id']) && $isPost) {
$userTable = new Default_Model_DbTable_User();
if (false === current($userTable->find($value['creator_user_id']))) {
$this->_error(self::CREATOR_USER_ID_INVALID, $value['creator_user_id']);
}
} elseif ($isPost) {
$this->_error(self::CREATOR_USER_ID_REQUIRED);
}
return $partialHappened;
}
开发者ID:nestorfabian,项目名称:REST-Example-App-for-Zend-Framework,代码行数:36,代码来源:Entry.php
示例4: _isValid
/**
* @param array $value
* @return boolean indicating is any valid data of interest was passed
*/
protected function _isValid($value)
{
$partialHappened = false;
$isPost = 'post' == $this->getMethodContext();
// validate that the title is set
if (isset($value['title'])) {
$partialHappened = true;
$validate = new Zend_Validate_StringLength(array(1, 100));
if (!$validate->isValid($value['title'])) {
$this->_addValidateMessagesAndErrors($validate);
}
$communityTable = new Default_Model_DbTable_Community();
if ($communityTable->fetchRow(array('title = ?' => $value['title']))) {
$this->_error(self::TITLE_ALREADY_EXISTS, $value['title']);
}
} elseif ($isPost) {
$this->_error(self::TITLE_REQUIRED);
}
// validate that the pic value is reasonable
if (isset($value['pic'])) {
$partialHappened = true;
$validate = new Zend_Validate_StringLength(array(0, 2083));
if (!$validate->isValid($value['pic'])) {
$this->_addValidateMessagesAndErrors($validate);
}
}
return $partialHappened;
}
开发者ID:nestorfabian,项目名称:REST-Example-App-for-Zend-Framework,代码行数:39,代码来源:Community.php
示例5: init
public function init()
{
/* Form Elements & Other Definitions Here ... */
$element = new Zend_Form_Element_Text('login');
$element->setLabel('Login')->setRequired();
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage('Le login est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
$element->addValidator($validator);
$validator = new Zend_Validate_StringLength();
$validator->setMax(40);
$element->addValidator($validator);
$filter = new Zend_Filter_StringTrim();
$element->addFilter($filter);
$this->addElement($element);
$element = new Zend_Form_Element_Password('password');
$element->setLabel('Mot de passe')->setRequired();
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage('Le mot de passe est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
$element->addValidator($validator);
$validator = new Zend_Validate_StringLength();
$validator->setMax(40);
$element->addValidator($validator);
$filter = new Zend_Filter_StringTrim();
$element->addFilter($filter);
$this->addElement($element);
}
开发者ID:bioub,项目名称:Formation_ZF1_Viveris_2016_02,代码行数:26,代码来源:Login.php
示例6: init
/**
* (non-PHPdoc)
* @see Zend_Form::init()
*/
public function init()
{
#$this->_addClassNames('well');
$this->setMethod(Zend_Form::METHOD_POST);
$this->setTranslator();
$this->setAttrib('id', 'frmlogin');
$txtEmail = $this->createElement('text', 'email')->setLabel("ACL_EMAIL")->setRequired(TRUE)->setAttrib('placeholder', '[email protected]')->addFilters(array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim()))->addValidator(new Zend_Validate_EmailAddress());
#$txtEmail->setDescription('Complete the email');
$this->addElement($txtEmail);
$txtPassword = $this->createElement('password', 'password')->setLabel("ACL_PASSWORD")->setRequired(TRUE)->setAttrib('placeholder', '*******');
#->setAttrib('size', 40);
$length = new Zend_Validate_StringLength(6, 50);
$length->setMessages(array('stringLengthTooShort' => sprintf($this->getTranslator()->translate('VALIDATE_PASSWORD_MIN'), 6), 'stringLengthTooLong' => sprintf($this->getTranslator()->translate('VALIDATE_PASSWORD_MAX'), 50)));
$txtPassword->addValidator($length);
$this->addElement($txtPassword);
#$token = new Zend_Form_Element_Hash('token');
$token = $this->createElement('hash', 'csrflogintoken');
$token->setSalt(md5(uniqid(rand(), TRUE)));
$token->setTimeout(300);
$token->setDecorators(array('ViewHelper'));
$this->addElement($token);
$submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_SUCCESS, 'type' => 'submit', 'buttonType' => 'success');
$btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
#$btnSubmit = $this->createElement('submit', 'submit');
$btnSubmit->setLabel('ACL_LOGIN');
$btnSubmit->removeDecorator('Label');
$btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
$btnSubmit->removeDecorator('Label');
$this->addElement($btnSubmit);
}
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:34,代码来源:Login.php
示例7: init
public function init()
{
/* Form Elements & Other Definitions Here ... */
// TODO setMethod
$element = new Zend_Form_Element_Text('prenom');
$element->setLabel('Prénom')->setRequired();
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage('Le prénom est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
$element->addValidator($validator);
$validator = new Zend_Validate_StringLength();
$validator->setMax(40);
$element->addValidator($validator);
$filter = new Zend_Filter_StringTrim();
$element->addFilter($filter);
$this->addElement($element);
$element = new Zend_Form_Element_Text('nom');
$element->setLabel('Nom')->setRequired();
$validator = new Zend_Validate_NotEmpty();
$validator->setMessage('Le nom est obligatoire', Zend_Validate_NotEmpty::IS_EMPTY);
$element->addValidator($validator);
$this->addElement($element);
$element = new Zend_Form_Element_Text('email');
$element->setLabel('Email');
$this->addElement($element);
$element = new Zend_Form_Element_Text('telephone');
$element->setLabel('Téléphone');
$this->addElement($element);
}
开发者ID:bioub,项目名称:Formation_ZF1_Viveris_2016_02,代码行数:28,代码来源:Contact.php
示例8: updateGroupsRows
public function updateGroupsRows($text, $id, $sportId)
{
if ($this->conn->checkAdmin()) {
$int = new Zend_Validate_Int();
if (!$int->isValid($id)) {
return $this->test;
}
if (!$int->isValid($sportId)) {
return $this->test;
}
$validator = new Zend_Validate_StringLength(2, 100);
if (!$validator->isValid($text)) {
return $this->test;
}
$query = "CALL updateGroups('" . $text . "','" . $id . "');";
$result = $this->conn->insert($query);
$query = "CALL selectGroups( '" . $sportId . "');CALL selectSports( )";
$result->message = $this->conn->multiresultbackArray($query);
return $result;
} else {
$this->test->type = "error";
$this->test->info = "nologin";
return $this->test;
}
}
开发者ID:anhvn,项目名称:bet-script,代码行数:25,代码来源:Groups.php
示例9: 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));
}
开发者ID:ankuradhey,项目名称:dealtrip,代码行数:59,代码来源:Contact.php
示例10: _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;
}
开发者ID:georgetutuianu,项目名称:licenta,代码行数:8,代码来源:SignupForm.php
示例11: validate
public function validate($excludeFromValidation = array())
{
if (!in_array('house_name', $excludeFromValidation)) {
$bookhouseSizeValidator = new Zend_Validate_StringLength(3, 20);
if (!$bookhouseSizeValidator->isValid($this->getHouseName())) {
$this->setValidationError('house_name', "Bookhouse name size must bee between 3-20");
}
}
}
开发者ID:berksonj,项目名称:bet,代码行数:9,代码来源:BookhouseModel.php
示例12: validateType
public function validateType($type)
{
$validator = new Zend_Validate_StringLength(2, 255);
if ($validator->isValid($type)) {
return true;
}
$msg = Sanmax_MessageStack::getInstance($this->_messagestack_name());
$msg->addMessage('pf_type', $validator->getMessages(), 'common');
return false;
}
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:10,代码来源:Validator.php
示例13: validatePassword
public function validatePassword($text, $name = 'example', $tab = 'common')
{
$validator = new Zend_Validate_StringLength(6, 32);
if ($validator->isValid($text)) {
return true;
}
$msg = Sanmax_MessageStack::getInstance($this->_namespace);
$msg->addMessage($name, $validator->getMessages(), $tab);
return false;
}
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:10,代码来源:Validator.php
示例14: _validateDescription
/**
* Validates job description
*
* @return boolean
*/
protected function _validateDescription()
{
$validator = new Zend_Validate_StringLength(2);
if ($validator->isValid($this->category->getDescription())) {
return true;
}
$msg = Sanmax_MessageStack::getInstance('SxCms_Job_Category');
$msg->addMessage('description', $validator->getMessages());
return false;
}
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:15,代码来源:BaseValidator.php
示例15: _validateIdentifier
protected function _validateIdentifier()
{
$validator = new Zend_Validate_StringLength(2, 255);
if ($validator->isValid($this->_group->getIdentifier())) {
return true;
}
$msg = Sanmax_MessageStack::getInstance('SxCms_Group');
$msg->addMessage('identifier', $validator->getMessages());
return false;
}
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:10,代码来源:BaseValidator.php
示例16: validateGroup
public function validateGroup()
{
$validator = new Zend_Validate_StringLength(2, 255);
$validator->setMessage($this->_tmx->_('error.verplicht.min'), Zend_Validate_StringLength::TOO_SHORT);
$validator->setMessage($this->_tmx->_('error.verplicht.max'), Zend_Validate_StringLength::TOO_LONG);
if ($validator->isValid($this->_group)) {
return true;
}
$msg = Sanmax_MessageStack::getInstance('SxModule_Securedocs_Group');
$msg->addMessage('group', $validator->getMessages(), 'settings');
return false;
}
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:12,代码来源:Group.php
示例17: isValid
public function isValid($value)
{
if (!parent::isValid($value)) {
return false;
}
$validator = new \Zend_Validate_StringLength();
$validator->setMax(128);
if (!$validator->isValid($value)) {
$this->_messages = $validator->getMessages();
return false;
}
return true;
}
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:13,代码来源:EmailAddress.php
示例18: setObservacao
/**
* Seta o valor da coluna observacao
*
* @param string $value
* @return Wf_Model_WfTransacao_Crud_Mapper
*/
public function setObservacao($value, $options = array('required' => true))
{
$this->_data['observacao'] = new ZendT_Type_String($value);
if ($options['db']) {
$this->_data['observacao']->setValueFromDb($value);
}
if (!$options['db']) {
$valid = new Zend_Validate_StringLength(array('max' => 300));
$valueValid = $this->_data['observacao']->getValueToDb();
if ($valueValid && !$valid->isValid($valueValid)) {
throw new ZendT_Exception_Business(implode("\n", $valid->getMessages()));
}
}
return $this;
}
开发者ID:rtsantos,项目名称:mais,代码行数:21,代码来源:Mapper.php
示例19: validateStr
public function validateStr($str, $type, $len)
{
//Check each post variable for blanks or spaces
$str_validator = new Zend_Validate_StringLength($len);
$str_validator->setMessage($type . ', \'%value%\', is too short. It must be at least %min% ' . 'characters.', Zend_Validate_StringLength::TOO_SHORT);
if ($str == $type || $str == "" || $str == " ") {
$error = "Please enter " . strtolower($type) . ".";
array_push($this->messages, $error);
}
if (!$str_validator->isValid($str)) {
foreach ($str_validator->getMessages() as $error) {
array_push($this->messages, $error);
}
}
return $this->messages;
}
开发者ID:kellancraddock,项目名称:portfolio,代码行数:16,代码来源:Message.php
示例20: updateTeamsRows
public function updateTeamsRows($text, $groupId, $id)
{
if ($this->conn->checkAdmin()) {
$validator = new Zend_Validate_StringLength(2, 100);
$int = new Zend_Validate_Int();
if (!$int->isValid($id)) {
return $this->test;
}
if (!$int->isValid($groupId)) {
return $this->test;
}
if (!$validator->isValid($text)) {
return $this->test;
}
$query = "call selectCheckForGroup('" . $id . "')";
$result = $this->conn->result($query);
if (!is_array($result)) {
$result->info = "grouperror";
$result->type = "error";
return $result;
}
$query = "CALL updateTeams ( '" . $text . "','" . $groupId . "','" . $id . "')";
return $this->conn->result($query);
} else {
$this->test->type = "error";
$this->test->info = "nologin";
return $this->test;
}
}
开发者ID:anhvn,项目名称:bet-script,代码行数:29,代码来源:Teams.php
注:本文中的Zend_Validate_StringLength类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论