本文整理汇总了PHP中Zend\InputFilter\Input::getValidatorChain方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::getValidatorChain方法的具体用法?PHP Input::getValidatorChain怎么用?PHP Input::getValidatorChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\InputFilter\Input
的用法示例。
在下文中一共展示了Input::getValidatorChain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInputFilter
public function getInputFilter()
{
$maxvalidator = new Validator\StringLength();
$maxvalidator->setMax(50);
$minvalidator = new Validator\StringLength();
$minvalidator->setMin(4);
$email = new Input('email');
$email->getValidatorChain()->attach(new Validator\EmailAddress());
$email->getValidatorChain()->attach($maxvalidator);
$email->getValidatorChain()->attach($minvalidator);
$password = new Input('password');
$password->getValidatorChain()->attach($maxvalidator);
$password->getValidatorChain()->attach(new Validator\StringLength(array('min' => 6)));
$first_name = new Input('first_name');
$first_name->getValidatorChain()->attach($maxvalidator);
$first_name->getValidatorChain()->attach($minvalidator);
$user_name = new Input('username');
$user_name->getValidatorChain()->attach($maxvalidator);
$user_name->getValidatorChain()->attach($minvalidator);
$inputFilter = new InputFilter();
$inputFilter->add($email);
$inputFilter->add($password);
$inputFilter->add($first_name);
$inputFilter->add($user_name);
return $inputFilter;
}
示例2: Input
function __construct()
{
parent::__construct('merchant_setting');
$this->add(array('name' => 'alipay_account', 'type' => 'Text'));
$this->add(array('name' => 'bank_type', 'type' => 'Text'));
$this->add(array('name' => 'bank_account_name', 'type' => 'Text'));
$this->add(array('name' => 'bank_account_card', 'type' => 'Text'));
$this->add(array('name' => 'submit', 'type' => 'Submit'));
/**
* Setting up inputFilter
*/
$input_AlipayAccount = new Input('alipay_account');
$input_AlipayAccount->setRequired(false);
$input_AlipayAccount->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)));
$input_AlipayAccount->getValidatorChain()->attach(new \Zend\Validator\EmailAddress());
$input_BankType = new Input('bank_type');
$input_BankType->setRequired(false);
$input_BankType->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)));
$input_BankAccountName = new Input('bank_account_name');
$input_BankAccountName->setRequired(false);
$input_BankAccountName->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)));
$input_BankAccountCard = new Input('bank_account_card');
$input_BankAccountCard->setRequired(false);
$input_BankAccountCard->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)));
$input_BankAccountCard->getValidatorChain()->attach(new \Zend\Validator\Digits());
$input_filter = new InputFilter();
$input_filter->add($input_AlipayAccount);
$input_filter->add($input_BankType);
$input_filter->add($input_BankAccountName);
$input_filter->add($input_BankAccountCard);
$this->setInputFilter($input_filter);
}
示例3: __construct
public function __construct(EntityExistValidator $entityExistValidator)
{
$this->inputFilter = new InputFilter();
$id = new Input('id');
$id->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0]);
$id->getValidatorChain()->attach($entityExistValidator);
$this->inputFilter->add($id);
}
示例4: __construct
public function __construct()
{
$senha = new Input('senha');
$senha->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$senha->getValidatorChain()->attach(new NotEmpty());
$this->add($senha);
$confsenha = new Input('conf-senha');
$confsenha->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$confsenha->getValidatorChain()->attach(new NotEmpty());
$confsenha->getValidatorChain()->attach(new Identical(array('token' => 'senha', 'messages' => array('notSame' => 'The two given passwords do not match', 'missingToken' => 'No password was provided to match against'))));
$this->add($confsenha);
}
示例5: __construct
public function __construct()
{
$num = new Input('num1');
$num->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$num->getValidatorChain()->attach(new NotEmpty());
$num->getValidatorChain()->attach(new Special());
$this->add($num);
$num1 = new Input('num2');
$num1->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$num1->getValidatorChain()->attach(new NotEmpty());
$num1->getValidatorChain()->attach(new Special());
$this->add($num1);
}
示例6: __construct
public function __construct()
{
$translator = new \Zend\I18n\Translator\Translator();
$translator->addTranslationFile('phparray', './module/Utenti/language/es.php');
$translatorMvc = new \Zend\Mvc\I18n\Translator($translator);
\Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc);
$nombre = new Input('nome');
$nombre->setRequired(true);
$nombre->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim');
$nombre->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
$this->add($nombre);
$password = new Input('password');
$password->setRequired(true);
$password->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum));
$this->add($password);
$confirmarPassword = new Input('confirmarPassword');
$confirmarPassword->setRequired(true);
$confirmarPassword->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum))->addValidator(new Identical(array('token' => 'password', 'messages' => array('notSame' => 'I dati sono errati, riprova.'))));
$this->add($confirmarPassword);
$imagen = new FileInput('immagine');
$imagen->setRequired(false);
$imagen->getFilterChain()->attach(new RenameUpload(array('target' => './httpdocs/immagine/utenti/utenti_', 'use_upload_extension' => true, 'randomize' => true)));
$imagen->getValidatorChain()->attach(new Size(array('max' => substr(ini_get('upload_max_filesize'), 0, -1) . 'MB')));
/*
$imagen->getValidatorChain()->attach(new MimeType(array(
'mimeType' => 'image/png,image/x-png,image/gif,image/jpeg,image/pjpeg', 'enableHeaderCheck' => true
)));
*/
$this->add($imagen);
}
示例7: __construct
public function __construct(array $categoria = array())
{
$this->categoria = $categoria;
//Titulo
$titulo = new Input('titulo');
$titulo->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$titulo->getValidatorChain()->attach(new NotEmpty());
$this->add($titulo);
//Descricao
$descricao = new Input('descricao');
$descricao->setRequired(false)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$this->add($descricao);
//Texto
$texto = new Input('texto');
$texto->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$texto->getValidatorChain()->attach(new NotEmpty());
$this->add($texto);
//ativo
$ativo = new Input('ativo');
$ativo->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$this->add($ativo);
$inArray = new InArray();
$inArray->setOptions(array('haystack' => $this->haystack($this->categoria)));
$categoria = new Input('category');
$categoria->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$categoria->getValidatorChain()->attach($inArray);
$this->add($categoria);
}
示例8: __construct
public function __construct(LabServiceInterface $labService, AssetServiceInterface $assetsService)
{
$labId = new Input('lab_id');
$labId->setRequired(true)->getFilterChain()->attach(new Filter\ToInt());
$labId->getValidatorChain()->attach(new Validator\NotEmpty());
$itemCategoryId = new Input('itemcategory_id');
$itemCategoryId->setRequired(true)->getFilterChain()->attach(new Filter\ToInt());
$itemCategoryId->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\Callback(['callback' => function ($value) use($assetsService) {
try {
$type = $assetsService->getItemCategoryById($value);
return $type && $type['id'] == $value;
} catch (Exception $ex) {
return false;
}
}, 'message' => 'Ο τύπος εξοπλισμού δεν είναι έγκυρος']));
$qty = new Input('qty');
$qty->setRequired(true)->getFilterChain()->attach(new Filter\ToInt());
$qty->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\GreaterThan(['min' => 0]));
$qtyacquired = new Input('qtyacquired');
$qtyacquired->setRequired(true)->getFilterChain()->attach(new Filter\ToInt());
$qtyacquired->getValidatorChain()->attach(new Validator\NotEmpty())->attach(new Validator\GreaterThan(['min' => 0, 'inclusive' => true]));
$reasons = new Input('reasons');
$reasons->setRequired(true)->getFilterChain()->attach(new Filter\StripTags())->attach(new Filter\StringTrim());
$reasons->getValidatorChain()->attach(new Validator\NotEmpty());
$this->add($labId)->add($itemCategoryId)->add($qty)->add($qtyacquired)->add($reasons);
}
示例9: __construct
public function __construct()
{
$email = new Input('email');
$email->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$email->getValidatorChain()->attach(new NotEmpty());
$this->add($email);
}
示例10: __construct
public function __construct()
{
$input = new Input('selectors');
$chain = $input->getValidatorChain();
$chain->attach(new Validator\ContentNegotiationSelectorsValidator());
$this->add($input);
}
示例11: __construct
public function __construct()
{
$nome = new Input('descricao');
$nome->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$nome->getValidatorChain()->attach(new NotEmpty());
$this->add($nome);
}
示例12: getInputFilter
public function getInputFilter()
{
if (is_null($this->filter)) {
$trackingIdValidator = new StringLength(36);
$regexValidator = new Regex('/^[a-zA-Z0-9_-]+$/');
$trackingIdInput = new Input('trackingId');
$trackingIdInput->allowEmpty();
$trackingIdInput->setRequired(false);
$trackingIdInput->getValidatorChain()->attach($trackingIdValidator)->attach($regexValidator);
$inArrayValidator = new InArray();
$inArrayValidator->setHaystack(array_keys($this->locations));
$originInput = new Input('origin');
$originInput->getValidatorChain()->attach($inArrayValidator);
$notSameValidator = new Callback(array('callback' => function ($value, $context = null) {
if ($context) {
return $value !== $context['origin'];
}
return true;
}, 'messages' => array(Callback::INVALID_VALUE => 'Origin and Destination are the same')));
$destinationInput = new Input('final_destination');
$destinationInput->getValidatorChain()->attach($inArrayValidator)->attach($notSameValidator);
$filter = new InputFilter();
$filter->add($trackingIdInput)->add($originInput)->add($destinationInput);
$this->filter = $filter;
}
return $this->filter;
}
示例13: buildFilter
public function buildFilter()
{
//category char 16 not null,
$category = new Input('category');
$category->setAllowEmpty(TRUE);
$category->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags')->attachByName('StringToLower');
$category->getValidatorChain()->attachByName('inArray', array('haystack' => $this->categories));
//title varchar 128 not null
$title = new Input('title');
$title->setAllowEmpty(TRUE);
$title->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags');
$titleRegex = new Regex(array('pattern' => '/^[a-zA-Z0-9 ]*$/'));
$titleRegex->setMessage('Title should contain only numbers, letters or spaces.');
$title->getValidatorChain()->attach($titleRegex)->attachByName('StringLength', array('min' => 1, 'max' => 128));
//date_created timestamp not null default current_timestamp
$dateCreated = new Input('dateCreated');
$dateCreated->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags');
$dateCreated->getValidatorChain()->attachByName('StringLength', array('min' => 10, 'max' => 10));
// date_expires timestamp not null default null
// descripton varchar 4096 default null
// photo_filename varchar 1024 default null
// contact_name varchar 255 default null
// contact_email varchar 255 default null
// contact_phone varchar 32 default null
// city varchar 128 default null
// country char 2 not null
// price decimal 12,2 not null
// delete_code char 16 character set utf8 collate utf8_bin default null
$this->add($category)->add($title)->add($dateCreated);
}
示例14: __construct
public function __construct()
{
$this->inputFilter = new InputFilter();
$id = new Input('id_equalTo');
$id->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0]);
$id->setRequired(false);
$mailTo = new Input('mailTo_like');
$mailTo->getFilterChain()->attachByName('StringTrim');
$mailTo->getValidatorChain()->attachByName('StringLength', ['min' => 0, 'max' => 50]);
$mailTo->setRequired(false);
$layoutId = new Input('layoutId_equalTo');
$layoutId->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0, 'max' => 1]);
$layoutId->setRequired(false);
$templateId = new Input('templateId_equalTo');
$templateId->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0, 'max' => 7]);
$templateId->setRequired(false);
$limit = new Input('limit');
$limit->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0]);
$limit->setRequired(false);
$page = new Input('page');
$page->getValidatorChain()->attachByName('Digits')->attachByName('GreaterThan', ['min' => 0]);
$page->setRequired(false);
$createdDtLessThen = new Input('createdDt_lessThan');
$createdDtLessThen->setRequired(false);
$createdDtGreaterThan = new Input('createdDt_greaterThan');
$createdDtGreaterThan->setRequired(false);
$this->inputFilter->add($id);
$this->inputFilter->add($mailTo);
$this->inputFilter->add($layoutId);
$this->inputFilter->add($templateId);
$this->inputFilter->add($limit);
$this->inputFilter->add($page);
$this->inputFilter->add($createdDtLessThen);
$this->inputFilter->add($createdDtGreaterThan);
}
示例15: __construct
public function __construct()
{
$login = new Input('login');
$login->setRequired(true)->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
$login->getValidatorChain()->attach(new NotEmpty());
$this->add($login);
}