本文整理汇总了PHP中Zend_Validate_StringLength::setMax方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_StringLength::setMax方法的具体用法?PHP Zend_Validate_StringLength::setMax怎么用?PHP Zend_Validate_StringLength::setMax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_StringLength
的用法示例。
在下文中一共展示了Zend_Validate_StringLength::setMax方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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));
}
示例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: testSetMinExceptionGreaterThanMax
/**
* Ensures that setMin() throws an exception when given a value greater than the maximum
*
* @return void
*/
public function testSetMinExceptionGreaterThanMax()
{
$max = 1;
$min = 2;
try {
$this->_validator->setMax($max)->setMin($min);
$this->fail('Expected Zend_Validate_Exception not thrown');
} catch (Zend_Validate_Exception $e) {
$this->assertEquals("The minimum must be less than or equal to the maximum length, but {$min} > {$max}", $e->getMessage());
}
}
示例6: 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;
}
示例7: 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;
}
示例8: _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;
}
示例9: 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;
}
}
示例10: init
public function init()
{
$this->setAttrib('class', 'form-horizontal');
$login = new Zend_Form_Element_Text('login');
$login->setLabel('Login')->setRequired();
$validator = new Zend_Validate_StringLength();
$validator->setMax(32);
$login->addValidator($validator);
$pass = new Zend_Form_Element_Password('pass');
$pass->setLabel('Mot de passe')->setRequired();
$hash = new Zend_Form_Element_Hash('hash');
$submit = new Zend_Form_Element_Submit('connexion');
$submit->setLabel('Se Connecter');
$this->addElements(array($login, $pass, $hash, $submit));
// add display group
$this->addDisplayGroup(array('login', 'pass', 'connexion'), 'users');
$this->getDisplayGroup('users')->setLegend('Se connecter');
// set decorators
EasyBib_Form_Decorator::setFormDecorator($this, EasyBib_Form_Decorator::BOOTSTRAP, 'connexion');
}
示例11: setLength
/**
* Set length
*
* @param $length
* @return Mage_Oauth_Model_Consumer_Validator_KeyLength
*/
public function setLength($length)
{
parent::setMax($length);
parent::setMin($length);
return $this;
}
示例12: _validatePhoto
protected function _validatePhoto()
{
$val = new Zend_Validate_StringLength();
$val->setMin(2);
$val->setMax(255);
$val->setMessage('Gelieve een geldige foto toe te voegen');
if ($val->isValid($this->_doctor->getPhoto())) {
return true;
}
$msg = Sanmax_MessageStack::getInstance('SxModule_Doctor');
$msg->addMessage('photo', $val->getMessages());
return false;
}
示例13: callTransactions
public function callTransactions($user, $datefirst, $datesecond, $status)
{
if ($this->conn->checkAdmin()) {
$validator = new Zend_Validate_StringLength(15, 20);
$int = new Zend_Validate_Int();
if (!$validator->isValid($datefirst)) {
return $this->test;
}
if (!$validator->isValid($datesecond)) {
return $this->test;
}
$validator->setMin(3);
$validator->setMax(6);
if (!$validator->isValid($status)) {
return $this->test;
}
if (!$int->isValid($user)) {
return $this->test;
}
$query = "call selectTransactions('" . $user . "','" . $datefirst . "','" . $datesecond . "','" . $status . "')";
return $this->conn->result($query);
} else {
if ($this->conn->checkUser()) {
$validator = new Zend_Validate_StringLength(15, 20);
$int = new Zend_Validate_Int();
if (!$validator->isValid($datefirst)) {
return $this->test;
}
if (!$validator->isValid($datesecond)) {
return $this->test;
}
$validator->setMin(3);
$validator->setMax(6);
if (!$validator->isValid($status)) {
return $this->test;
}
if (!$int->isValid($user)) {
return $this->test;
}
$userID = $this->conn->getAdminId();
$query = "call selectTransactions('" . $userID . "','" . $datefirst . "','" . $datesecond . "','" . $status . "')";
return $this->conn->result($query);
} else {
$this->test->type = "error";
$this->test->info = "nologin";
return $this->test;
}
}
}
示例14: init
/**
* @author Ngo Anh Long <ngoanhlong@gmail.com>
* If we use Twitter_Bootstrap3_Form_Horizontal to create a element follow format such as:
* $studentId = $this->createElement('text', 'studentId');
* Then: Type of element you must make it in lower case 'text'
* Because: If you make the type of element in uper case 'Text', bootstrap3 is not active for U
* Beside that: To create a element must follow the format:
* $studentId = $this->createElement('text', 'studentId');
* If you have a recommendation for me, please recomment for me
*/
public function init()
{
// Add some Attributes for this form
// Name of form is: createProfile and method is POST to itsefl
$this->addAttribs(['name' => 'createProfile']);
$this->setMethod("POST");
//Student Id
//Not empty
// Just contains number
// Max length: 25
// Min length: 6
$studentId = $this->createElement('text', 'studentId');
$studentId->setLabel('Mã sinh viên: ');
$studentId->setRequired();
$studentId->addValidator('NotEmpty', true, ['messages' => ['isEmpty' => 'Mã sinh viên yêu cầu không để trống']]);
$studentId->addValidator('digits', true, ['messages' => ['notDigits' => 'Mã sinh viên yêu cầu chỉ được là số']]);
$studentIdLengthValidate = new Zend_Validate_StringLength();
$studentIdLengthValidate->setMax(25);
$studentIdLengthValidate->setMin(6);
$studentIdLengthValidate->setMessage('Mã sinh viên tối thiểu là 6 kí tự', Zend_Validate_StringLength::TOO_SHORT);
$studentIdLengthValidate->setMessage('Mã sinh viên có độ dài tối đa là 25 kí tự', Zend_Validate_StringLength::TOO_LONG);
$studentId->addValidator($studentIdLengthValidate);
// studentName :
// Not empty
// Just contains: Alphabet and allow white space in it
// Max length: 50
// Min length: 6
$studentName = $this->createElement('text', 'studentName');
$studentName->setLabel("Your studentName");
$studentName->setRequired();
$studentName->addValidator('NotEmpty', true, ['messages' => ['isEmpty' => 'Tên sinh viên yêu cầu không để trống']]);
$studentName->addValidator('Alpha', true, ['allowWhiteSpace' => true, 'messages' => ['notAlpha' => 'Tên sinh viên chỉ là chữ']]);
$stringLengthValidate = new Zend_Validate_StringLength();
$stringLengthValidate->setMax(50);
$stringLengthValidate->setMin(6);
$stringLengthValidate->setMessage('Tên sinh viên tối thiểu là 6 kí tự', Zend_Validate_StringLength::TOO_SHORT);
$stringLengthValidate->setMessage('Tên sinh viên có độ dài tối đa là 50 kí tự', Zend_Validate_StringLength::TOO_LONG);
$studentName->addValidator($stringLengthValidate);
// dateOf birth:
// 1. Not Empty
// 2. Must follow this format: dd/mm/YYYY
$dateOfBirth = $this->createElement('text', 'dateOfBirth');
$dateOfBirth->setLabel("Date of birth: ");
$dateOfBirth->setAttrib('placeholder', 'dd/mm/YYYY');
$dateOfBirth->setRequired();
$dateOfBirth->addValidator('NotEmpty', true, ['messages' => ['isEmpty' => 'Ngày sinh yêu cầu không được để trống']]);
$dateValidator = new Zend_Validate_Date();
$dateValidator->setFormat('dd-MM-yyyy');
$dateValidator->setMessage("Ngày sinh của bạn phải theo định dạng: dd/mm/yyyy", Zend_Validate_Date::FALSEFORMAT);
$dateValidator->setMessage("Ngày sinh của bạn phải theo định dạng: dd/mm/yyyy", Zend_Validate_Date::INVALID_DATE);
$dateValidator->setMessage("Ngày sinh của bạn phải theo định dạng: dd/mm/yyyy", Zend_Validate_Date::INVALID);
$dateOfBirth->addValidator($dateValidator);
// Gender is a Select Box
// Default value is 1 - male
// And 0 - Female
// Gender don't need validate because it has default value
$gender = $this->createElement('select', "gender");
$gender->setValue("1");
$gender->setLabel("Gender");
$gender->setMultiOptions(['1' => 'Male', '0' => 'Female']);
// $gender->setRequired();
// $gender->addValidator('NotEmpty', true, [
// 'messages' => [
// 'isEmpty' => 'Giới tính yêu cầu không được để trống'
// ]
// ]);
// Phone number
// Must:
// 1. Not empty
// 2. Is Integer, dont allow white space
// After this validator, when get phone number, add number 0 to head of phone number
// Max length: 12
// Min length: 11
// Note: this rule follows number of Vietnamese phone number
$phone = $this->createElement('text', 'phone');
$phone->setLabel("Your phone: ");
$phone->setRequired();
$phone->addValidator('NotEmpty', true, ['messages' => ['isEmpty' => 'Số điện thoại yêu cầu không để trống']]);
$phoneDigitValidator = new Zend_Validate_Int();
$phoneDigitValidator->setMessage('Số điện thoại chỉ bao gồm các chữ số nguyên', Zend_Validate_Int::NOT_INT);
$phoneLengthValidator = new Zend_Validate_StringLength();
$phoneLengthValidator->setMax(12);
$phoneLengthValidator->setMin(11);
$phoneLengthValidator->setMessage('Số điện thoại tối thiểu 11 chữ số', Zend_Validate_StringLength::TOO_SHORT);
$phoneLengthValidator->setMessage("Số điện thoại chỉ tối đa 12 chữ số", Zend_Validate_StringLength::TOO_LONG);
$phone->addValidator($phoneDigitValidator);
$phone->addValidator($phoneLengthValidator);
// Address
// Contains: 40 columns and 10 rows
// Address can empty is Ok
//.........这里部分代码省略.........
示例15: selectUserPlacedBets
public function selectUserPlacedBets($id, $datefirst, $datesecond, $status)
{
if ($this->conn->checkAdmin()) {
$int = new Zend_Validate_Int();
if (!$int->isValid($id)) {
return $this->test;
}
$timeval = new Zend_Validate_StringLength(15, 20);
if (!$timeval->isValid($datefirst)) {
return $this->test;
}
if (!$timeval->isValid($datesecond)) {
return $this->test;
}
$timeval->setMin(1);
$timeval->setMax(10);
if (!$timeval->isValid($status)) {
return $this->test;
}
$query = "call select_bet_slip_user_admin('" . $id . "','" . $datefirst . "','" . $datesecond . "','" . $status . "');";
return $this->conn->multiresultbackArray($query);
} else {
$userID = $this->conn->getAdminId();
if ($this->conn->checkUser()) {
$int = new Zend_Validate_Int();
if (!$int->isValid($id)) {
return $this->test;
}
$timeval = new Zend_Validate_StringLength(15, 20);
if (!$timeval->isValid($datefirst)) {
return $this->test;
}
if (!$timeval->isValid($datesecond)) {
return $this->test;
}
$timeval->setMin(1);
$timeval->setMax(10);
if (!$timeval->isValid($status)) {
return $this->test;
}
$query = "call select_bet_slip_user_admin('" . $userID . "','" . $datefirst . "','" . $datesecond . "','" . $status . "');";
return $this->conn->multiresultbackArray($query);
} else {
$this->test->type = "error";
$this->test->info = "nologin";
return $this->test;
}
}
}