public function prepareFilters() { $who = new Input('who'); $who->getFilterChain()->attachByName('StripTags'); $what = new Input('what'); $who->getFilterChain()->attachByName('StripTags'); }
public function __construct() { $search = new Input('search'); $search->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $search->getValidatorChain()->attachByName('StringLength', array('min' => 1, 'max' => 128)); $this->add($search); }
public function __construct(EntityManager $objectManager) { // Nom $nom = new Input('nom'); $nom->getFilterChain()->attach(new StringTrim())->attach(new StripTags()); $nom->getValidatorChain()->attach(new NotEmpty())->attach(new StringLength(array('max' => 50))); $this->add($nom); // Image $image = new Input('image'); $image->setRequired(false); // TODO $this->add($image); // Date début $dateDebut = new Input('dateDebut'); $dateDebut->setRequired(true); //->getValidatorChain() //->attach(new DateTime(array('format' => 'd/m/Y'))); // TODO //$this->add($dateDebut); // Date fin $dateFin = new Input('dateFin'); $dateFin->setRequired(true); //->getValidatorChain() //->attach(new DateTime(array('format' => 'd/m/Y'))); // TODO //$this->add($dateFin); // TODO joueurs }
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); }
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); }
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); }
public function __construct() { // Email $email = new Input('email'); $email->getFilterChain()->attach(new StringTrim())->attach(new StripTags()); $email->getValidatorChain()->attach(new NotEmpty())->attach(new StringLength(array('max' => 255)))->attach(new EmailAddress()); $this->add($email); }
public function __construct() { $loginEmail = new Input('loginEmail'); $loginEmail->setRequired(true); $loginEmail->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $loginEmail->getValidatorChain()->addValidator(new EmailAddress(array('domain' => false))); $this->add($loginEmail); $this->add(array('name' => 'loginPassword', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')))); }
public function __construct() { $this->add(array('name' => 'name', 'required' => TRUE, 'filters' => array(array('name' => 'StripTags')), 'validators' => array(array('name' => 'stringLength', 'options' => array('min' => 5, 'max' => 20))))); $e = new Input('password'); $e->setRequired(true); $e->getValidatorChain()->attach(new StringLength(array('encoding' => 'UTF-8', 'min' => 6, 'max' => 32))); $e->getFilterChain()->attach(new StringTrim()); $this->add($e); }
public function addInputFilter() { $file = new InputFilter\Input('file'); $file->getValidatorChain()->attach(new Validator\File\Size(array('max' => 3100000)))->attach(new Validator\File\ImageSize(array('minWidth' => 600, 'minHeight' => 600))); $file->getFilterChain()->attachByName('filerenameupload', array('target' => './public/uploads/', 'randomize' => true)); //-- Bind filters --------------------------------- $inputFilters = new InputFilter\InputFilter(); $inputFilters->add($file); $this->setInputFilter($inputFilters); }
public function buildFilter() { $listingsId = new Input('listings_id'); $listingsId->getFilterChain()->attach(new StripTags())->attach(new StringTrim())->attach(new StringToLower()); $listingsId->getValidatorChain()->attachByName('Digits'); $deleteCode = new Input('delete_code'); $deleteCode->setAllowEmpty(TRUE); $deleteCode->getFilterChain()->attach(new StripTags())->attach(new StringTrim()); $deleteCode->getValidatorChain()->attachByName('Alnum', array('allowWhiteSpace' => false)); $this->add($listingsId)->add($deleteCode); }
public function buildFilter() { /****************************************************************** * Isto é um exemplo de como realizar a configurações do filtro, * O importante é registrar o campos do formulário pedidos no exercícios **********************************************************************/ // filter & validate by fields $category = new Input('category'); $category->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags')->attachByName('StringToLower'); $category->getValidatorChain()->attachByName('InArray', array('haystack' => $this->getCategories())); $title = new Input('title'); $title->getFilterChain()->attachByName('StringTrim')->attachByName('StripTags'); $titleRegex = new Regex(array('pattern' => '/^[a-zA-Z0-9 ]*$/')); $titleRegex->setMessage('Title should only contain numbers, letters or spaces!'); $title->getValidatorChain()->attach($titleRegex)->attachByName('StringLength', array('min' => 1, 'max' => 128)); $photo = new Input('photo_filename'); $photo->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $photo->getValidatorChain()->attachByName('Regex', array('pattern' => '!^(http://)?[a-z0-9./_-]+(jp(e)?g|png)$!i')); $photo->setErrorMessage('Photo must be a URL or a valid filename ending with jpg or png'); $price = new Input('price'); $price->setAllowEmpty(TRUE); $price->getValidatorChain()->addByName('GreaterThan', array('min' => 0.0)); $price->getFilterChain()->attach(new Float()); // custom filter $expires = new Input('expires'); $expires->setAllowEmpty(TRUE); $expires->getValidatorChain()->attachByName('InArray', array('haystack' => array_keys($this->getExpireDays()))); $expires->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $city = new Input('cityCode'); $city->setAllowEmpty(TRUE); $city->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $name = new Input('contact_name'); $name->setAllowEmpty(TRUE); $name->getValidatorChain()->attachByName('Regex', array('pattern' => '/^[a-z0-9., -]{1,255}$/i')); $name->setErrorMessage('Name should only contain letters, numbers, and some punctuation.'); $name->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $phone = new Input('contact_phone'); $phone->setAllowEmpty(TRUE); $phone->getValidatorChain()->attachByName('Regex', array('pattern' => '/^\\+?\\d{1,4}(-\\d{3,4})+$/')); $phone->setErrorMessage('Phone number must be in this format: +nnnn-nnn-nnn-nnnn'); $phone->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $email = new Input('contact_email'); $email->setAllowEmpty(TRUE); $email->getValidatorChain()->attachByName('EmailAddress'); $email->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $description = new Input('description'); $description->setAllowEmpty(TRUE); $description->getValidatorChain()->attachByName('StringLength', array('min' => 1, 'max' => 4096)); $description->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $delCode = new Input('delete_code'); $delCode->setRequired(TRUE); $delCode->getValidatorChain()->addByName('Digits'); $this->add($category)->add($title)->add($photo)->add($price)->add($expires)->add($city)->add($name)->add($phone)->add($email)->add($description)->add($delCode); }
public function __construct() { $translator = new \Zend\I18n\Translator\Translator(); $translator->addTranslationFile('phparray', './module/Posterlabs/language/es.php'); $translatorMvc = new \Zend\Mvc\I18n\Translator($translator); \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc); $nombre = new Input('titolo'); $nombre->setRequired(true); $nombre->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $nombre->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum)); $this->add($nombre); $this->add(array('name' => 'durata', 'required' => true, 'validators' => array(array('name' => 'Int')))); }
/** * Return an instance of InputFilter * * @return InputFilter */ public function getInputFilter() { if (!isset($this->inputFilter)) { $inputFilter = parent::getInputFilter(); // count $count = new Input('count'); $count->setAllowEmpty(true); $count->getFilterChain()->attach(new Int()); $count->getValidatorChain()->attach(new Digits()); $inputFilter->add($count); $this->inputFilter = $inputFilter; } return $this->inputFilter; }
public function __construct() { // Email $email = new Input('email'); $email->getFilterChain()->attach(new StringTrim())->attach(new StripTags()); $email->getValidatorChain()->attach(new NotEmpty())->attach(new StringLength(array('max' => 255)))->attach(new EmailAddress()); $this->add($email); // Password $password = new Input('encryptedPassword'); $password->setRequired(true); $password->getFilterChain()->attach(new StringTrim()); $password->getValidatorChain()->attach(new NotEmpty())->attach(new StringLength(array('min' => 6, 'max' => 32))); $this->add($password); }
public function buildFilter() { $category = new Input('category'); $category->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim')->attachByName('StringToLower'); $category->getValidatorChain()->attachByName('InArray', array('haystack' => $this->getCategories())); $title = new Input('title'); $title->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $titleRegex = new Regex(array('pattern' => '/^[a-zA-Z0-9 ]*$/')); $title->getValidatorChain()->attach($titleRegex)->attachByName('StringLength', array('min' => 1, 'max' => 128)); $photo = new Input('photo_filename'); $photo->setRequired(FALSE); $photo->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $photo->getValidatorChain()->attachByName('Regex', array('pattern' => '!^(http(s)?://)?[a-z0-9./_-]+(jp(e)?g|png)$!i')); $photo->setErrorMessage('Photo must be a URL or a valid filename ending with jpg or png'); $name = new Input('contact_name'); $name->setAllowEmpty(TRUE); $name->getValidatorChain()->attachByName('Regex', array('pattern' => '/^[a-z0-9. -]{1,255}$/i')); $name->setErrorMessage('Name should only contain letters, numbers, spaces, . or -.'); $name->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $email = new Input('contact_email'); $email->setAllowEmpty(TRUE); $email->getValidatorChain()->attachByName('EmailAddress'); $email->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $phone = new Input('contact_phone'); $phone->setAllowEmpty(TRUE); $phone->getValidatorChain()->attachByName('Regex', array('pattern' => '/^\\+?\\d{1,4}(-\\d{3,4})+$/')); $phone->setErrorMessage('Phone number must be in the format +nnnn-nnn-nnn-nnnn'); $phone->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $city = new Input('city'); $city->setAllowEmpty(TRUE); $city->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $city->getValidatorChain()->attachByName('InArray', array('haystack' => PostForm::$cityCodes)); $price = new Input('price'); $price->setAllowEmpty(TRUE); $price->getValidatorChain()->attachByName('GreaterThan', array('min' => 0.0)); $price->getFilterChain()->attach(new Float()); $expires = new Input('expires'); $expires->setAllowEmpty(TRUE); $expires->getValidatorChain()->attachByName('InArray', array('haystack' => array_keys($this->getExpireDays()))); $expires->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $deleteCode = new Input('delete_code'); $deleteCode->setRequired(TRUE); $deleteCode->getValidatorChain()->attachByName('Digits'); $description = new Input('description'); $description->setAllowEmpty(TRUE); $description->getValidatorChain()->attachByName('StringLength', array('min' => 1, 'max' => 4096)); $description->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $this->add($category)->add($title)->add($photo)->add($name)->add($email)->add($phone)->add($city)->add($price)->add($expires)->add($deleteCode)->add($description); }
public function getChildInputFilter() { $filter = new BaseInputFilter(); $foo = new Input(); $foo->getFilterChain()->attachByName('stringtrim')->attachByName('alpha'); $foo->getValidatorChain()->attach(new Validator\StringLength(3, 6)); $bar = new Input(); $bar->getFilterChain()->attachByName('stringtrim'); $bar->getValidatorChain()->attach(new Validator\Digits()); $baz = new Input(); $baz->setRequired(false); $baz->getFilterChain()->attachByName('stringtrim'); $baz->getValidatorChain()->attach(new Validator\StringLength(1, 6)); $filter->add($foo, 'foo')->add($bar, 'bar')->add($baz, 'baz'); return $filter; }
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); $messaggio = new Input('messaggio'); $messaggio->setRequired(true); $messaggio->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); // $messaggio->getValidatorChain() // ->addValidator(new StringLength($this->opcionesStringLenght)); $this->add($messaggio); $this->add(array('name' => 'posterlab', 'required' => true, 'validators' => array(array('name' => 'Int')))); $this->add(array('name' => 'tipo', 'required' => true, 'validators' => array(array('name' => 'Int')))); $this->add(array('name' => 'sessione', 'required' => true, 'validators' => array(array('name' => 'Int')))); }
public function buildFilter() { $category = new Input('category'); $category->getFilterChain()->attach(new StripTags())->attach(new StringTrim())->attach(new StringToLower()); $category->getValidatorChain()->attach(new InArray(array('haystack' => $this->categories))); $title = new Input('title'); $title->getFilterChain()->attach(new StripTags())->attach(new StringTrim()); $title->getValidatorChain()->attachByName('Alnum', array('allowWhiteSpace' => TRUE))->attachByName('StringLength', array('options' => array('min' => 6, 'max' => 128))); $price = new Input('price'); $price->getFilterChain()->attach(new StripTags())->attach(new StringTrim()); $priceRegex = new \Zend\Validator\Regex(array('pattern' => '/^[0-9]{1,10}+(\\.[0-9]{1,2})?$/')); $priceRegex->setMessage('Preço deve ter no máximo 12 caracteres, incluindo opcionalmente 2 casas decimais separadas por ".".'); $price->getValidatorChain()->attach($priceRegex); $dateExpires = new Input('date_expires'); $dateExpires->setAllowEmpty(TRUE); $dateExpires->getValidatorChain()->attach(new InArray(array('haystack' => $this->dateExpires))); $description = new Input('description'); $description->setAllowEmpty(TRUE); $description->getFilterChain()->attach(new StripTags())->attach(new StringTrim()); $description->getValidatorChain()->attachByName('StringLength', array('options' => array('max' => 4096))); $photoFilename = new Input('photo_filename'); $photoFilename->setAllowEmpty(TRUE); $photoFilename->getValidatorChain()->attachByName('Regex', array('pattern' => '!^(http://)?[a-z0-9./_-]+(jp(e)?g|png)$!i')); $photoFilename->setErrorMessage('Photo must be a URL or a valid filename ending with jpg or png'); $contactName = new Input('contact_name'); $contactName->getFilterChain()->attach(new StripTags())->attach(new StringTrim()); $contactName->getValidatorChain()->attachByName('Regex', array('pattern' => '/^[a-z0-9., -]{1,255}$/i')); $contactName->setErrorMessage('Name should only contain letters, numbers, and some punctuation.'); $contactEmail = new Input('contact_email'); $contactEmail->setAllowEmpty(TRUE); $contactEmail->getFilterChain()->attach(new StripTags())->attach(new StringTrim()); $contactEmail->getValidatorChain()->attachByName('EmailAddress'); $contactPhone = new Input('contact_phone'); $contactPhone->setAllowEmpty(TRUE); $contactPhone->getFilterChain()->attach(new StripTags())->attach(new StringTrim()); $contactPhone->getValidatorChain()->attachByName('Regex', array('pattern' => '/^(\\([0-9]{2}\\))\\s([9]{1})?([0-9]{4})-([0-9]{4})$/')); $contactPhone->setErrorMessage('Contato deve ter o seguinte formato:(99) 9999-9999 ou (99) 99999-9999'); $cityCode = new Input('cityCode'); $cityCode->setAllowEmpty(TRUE); $cityCode->getFilterChain()->attach(new StripTags())->attach(new StringTrim()); $cityCode->getValidatorChain()->attach(new InArray(array('haystack' => array_keys($this->cities)))); $deleteCode = new Input('delete_code'); $deleteCode->setAllowEmpty(TRUE); $deleteCode->getFilterChain()->attach(new StripTags())->attach(new StringTrim()); $deleteCode->getValidatorChain()->attachByName('Alnum', array('allowWhiteSpace' => TRUE)); $this->add($category)->add($title)->add($price)->add($dateExpires)->add($description)->add($photoFilename)->add($contactName)->add($contactEmail)->add($contactPhone)->add($cityCode)->add($deleteCode); }
public function __construct(EntityManager $objectManager, $type) { // Firstname $firstname = new Input('prenom'); $firstname->getFilterChain()->attach(new StringTrim())->attach(new StripTags()); $firstname->getValidatorChain()->attach(new NotEmpty())->attach(new StringLength(array('max' => 50))); $this->add($firstname); // Lastname $lastname = new Input('nom'); $lastname->getFilterChain()->attach(new StringTrim())->attach(new StripTags()); $lastname->getValidatorChain()->attach(new NotEmpty())->attach(new StringLength(array('max' => 50))); $this->add($lastname); //Unique email validator $uniqueUserEmail = new UniqueObject(array('object_manager' => $objectManager, 'object_repository' => $objectManager->getRepository('Application\\Entity\\Utilisateur'), 'fields' => 'email', 'use_context' => true)); $uniqueUserEmail->setMessage('L\'email renseigné est déjà utilisé par un autre utilisateur.', 'objectNotUnique'); // Email $email = new Input('email'); $email->getFilterChain()->attach(new StringTrim())->attach(new StripTags()); $email->getValidatorChain()->attach(new NotEmpty())->attach(new StringLength(array('max' => 255)))->attach(new EmailAddress())->attach($uniqueUserEmail); $this->add($email); $editCallback = new Callback(function ($value) { if ($value == '') { return true; } /** @var StringLength $validator */ $validator = new StringLength(array('min' => 6, 'max' => 32)); return $validator->isValid($value); }); $editCallback->setMessage('Le mot de passe doit contenir entre 6 et 32 caractères.'); // Password $password = new Input('password'); $password->setRequired($type == UtilisateurForm::TYPE_ADD)->setContinueIfEmpty(true); $password->getFilterChain()->attach(new StringTrim()); $password->getValidatorChain()->attach($type == UtilisateurForm::TYPE_ADD ? new StringLength(array('min' => 6, 'max' => 32)) : $editCallback); $this->add($password); // Password Confirmation $passwordConfirmation = new Input('passwordConfirmation'); $passwordConfirmation->setRequired($type == UtilisateurForm::TYPE_ADD)->setContinueIfEmpty(true); $passwordConfirmation->getFilterChain()->attach(new StringTrim()); $passwordConfirmation->getValidatorChain()->attach($type == UtilisateurForm::TYPE_ADD ? new StringLength(array('min' => 6, 'max' => 32)) : $editCallback)->attach(new Identical('password')); $this->add($passwordConfirmation); $role = new Input('role'); $role->setRequired(false); $role->getFilterChain()->attach(new Digits()); $this->add($role); }
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)); $this->add($password); }
function __construct() { parent::__construct('withdraw_edit'); $this->add(array('name' => 'withdraw_interface_trade_id', 'type' => 'Text')); $this->add(array('type' => 'Zend\\Form\\Element\\Radio', 'name' => 'pay_status', 'options' => array('value_options' => array(Withdraw::WITHDRAW_PAY_STATUS_NO => 'No', Withdraw::WITHDRAW_PAY_STATUS_YES => 'Yes')))); $this->add(array('name' => 'submit', 'type' => 'Submit')); /** * Setting up inputFilter */ $input_PayStatus = new Input('pay_status'); $input_PayStatus->getFilterChain()->attach(new \Zend\Filter\Whitelist(array('list' => array(Withdraw::WITHDRAW_PAY_STATUS_NO, Withdraw::WITHDRAW_PAY_STATUS_YES)))); $input_WithdrawInterfaceTradeId = new Input('withdraw_interface_trade_id'); $input_WithdrawInterfaceTradeId->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50))); $input_filter = new InputFilter(); $input_filter->add($input_PayStatus); $this->setInputFilter($input_filter); }
/** * {@inheritdoc} */ public function init() { // Inicialização $pAccounts = $this->getServiceLocator()->getServiceLocator()->get('Balance\\Model\\Persistence\\Accounts'); // Verificações if (!$pAccounts instanceof ValueOptionsInterface) { throw new InputFilterException('Invalid Model'); } // Chave Primária $input = new Input(); $input->getFilterChain()->attach(new Filter\ToInt()); $this->add($input, 'id'); // Data e Hora $input = new Input(); $input->getValidatorChain()->attach(new I18n\Validator\DateTime(['dateType' => IntlDateFormatter::MEDIUM, 'timeType' => IntlDateFormatter::MEDIUM])); $this->add($input, 'datetime'); // Descrição $this->add(new Input(), 'description'); // Filtro: Entradas $filter = new InputFilter(); // Entradas: Tipo $input = new Input(); $input->getValidatorChain()->attach(new Validator\InArray(['haystack' => array_keys((new EntryType())->getDefinition())])); $filter->add($input, 'type'); // Capturar Todas as Possíveis Entradas de Contas $options = []; foreach ($pAccounts->getValueOptions() as $identifier => $option) { if (is_array($option)) { $options = array_merge($options, array_keys($option['options'])); } else { $options = array_merge($options, [$identifier]); } } // Entradas: Conta $input = new Input(); $input->getValidatorChain()->attach(new Validator\InArray(['haystack' => $options]))->attach(new Validator\Callback(['callback' => [$this, 'doValidateAccountId'], 'message' => 'O valor de entrada foi configurado em outra entrada de lançamento'])); $input->getFilterChain()->attach(new Filter\ToInt()); $filter->add($input, 'account_id'); // Entradas: Valor $input = new Input(); $input->getValidatorChain()->attach(new Validator\Regex(['pattern' => '/^[1-9]*[0-9]+,[0-9]{2}$/', 'message' => 'O valor informado não está no formato esperado']))->attach(new Validator\Callback(['callback' => [$this, 'doValidateValue'], 'message' => 'O valor de entrada não está balanceado'])); $filter->add($input, 'value'); // Coleção: Entradas $collection = (new CollectionInputFilter())->setInputFilter($filter)->setCount(2); $this->add($collection, 'entries'); }
public function __construct() { parent::__construct('password'); $this->filter = new InputFilter(); $oldPassword = new Element\Password('oldPassword'); $oldPassword->setAttribute('required', true); $oldPassword->setAttribute('placeholder', 'Current Password'); $this->add($oldPassword); $oldPasswordFilter = new Input('oldPassword'); $oldPasswordFilter->setRequired(true); $this->filter->add($oldPasswordFilter); $newPassword = new Element\Password('newPassword'); $newPassword->setAttribute('required', true); $newPassword->setAttribute('placeholder', 'New Password'); $this->add($newPassword); $newPasswordFilter = new Input('newPassword'); $newPasswordFilter->setRequired(true); $newPasswordFilter->getFilterChain()->attach(new Filter\StringTrim()); $newPasswordFilter->getValidatorChain()->attach(new AppValidator\PasswordStrength()); $this->filter->add($newPasswordFilter); $confirmPassword = new Element\Password('confirmPassword'); $confirmPassword->setAttribute('required', true); $confirmPassword->setAttribute('placeholder', 'Confirm New Password'); $this->add($confirmPassword); $confirmPasswordFilter = new Input('confirmPassword'); $confirmPasswordFilter->setRequired(true); $confirmPasswordFilter->getFilterChain()->attach(new Filter\StringTrim()); $confirmPasswordFilter->getValidatorChain()->attach(new Validator\Identical('newPassword')); $this->filter->add($confirmPasswordFilter); $buttons = new Form('buttons'); $buttons->setOption('twb-layout', 'inline'); $buttons->setAttribute('class', 'form-group'); $submit = new Element\Submit('submit'); $submit->setAttribute('class', 'btn-primary pull-right'); $submit->setOption('glyphicon', 'lock'); $submit->setLabel('Change Password'); $buttons->add($submit); $cancel = new Element\Submit('cancel'); $cancel->setAttribute('formnovalidate', true); $cancel->setAttribute('class', 'btn-warning pull-right'); $cancel->setOption('glyphicon', 'ban-circle'); $cancel->setLabel('Cancel'); $buttons->add($cancel); $this->add($buttons); }
function __construct($payment_type) { parent::__construct($payment_type); $this->add(array('name' => 'name', 'type' => 'Hidden', 'attributes' => array('value' => $payment_type))); $this->add(array('name' => 'merchant_id', 'type' => 'Text')); $this->add(array('name' => 'api_key', 'type' => 'Text')); $this->add(array('name' => 'account', 'type' => 'Text')); $this->add(array('name' => 'option', 'type' => 'Text')); $this->add(array('name' => 'submit', 'type' => 'Submit')); /** * Setting up inputFilter */ $input_Name = new Input('name'); $input_Name->getFilterChain()->attach(new \Zend\Filter\Whitelist(array('list' => array(PaymentInterface::PAYMENT_TYPE_ALIPAY, PaymentInterface::PAYMENT_TYPE_WXPAY)))); $input_filter = new InputFilter(); $input_filter->add($input_Name); $this->setInputFilter($input_filter); }
function __construct(\Merchant\Model\Report $report) { parent::__construct('withdraw'); $this->add(array('name' => 'withdraw_type', 'type' => 'Select', 'options' => array('label' => 'Which is your WithdrawType ?', 'value_options' => array(Withdraw::WITHDRAW_TYPE_ALIPAY => 'Alipay', Withdraw::WITHDRAW_TYPE_BANK => 'BankCard')))); $this->add(array('name' => 'price', 'type' => 'Number')); $this->add(array('name' => 'submit', 'type' => 'Submit')); /** * Setting up inputFilter */ $input_WithdrawType = new Input('withdraw_type'); $input_WithdrawType->getFilterChain()->attach(new \Zend\Filter\Whitelist(array('list' => array(Withdraw::WITHDRAW_TYPE_ALIPAY, Withdraw::WITHDRAW_TYPE_BANK)))); $input_Price = new Input('price'); $input_Price->getValidatorChain()->attach(new \Zend\I18n\Validator\IsFloat())->attach(new \Zend\Validator\Between(array('min' => 100, 'max' => $report->EnableMakeWithdraw))); $input_filter = new InputFilter(); $input_filter->add($input_WithdrawType); $input_filter->add($input_Price); $this->setInputFilter($input_filter); }
/** * @param ServiceLocatorInterface $serviceLocator * * @return InputFilter */ public function createService(ServiceLocatorInterface $serviceLocator) { $username = new Input(); $username->setName('username'); $username->setRequired(true); $username->setAllowEmpty(false); $username->getFilterChain()->attach(new StringTrim())->attach(new StripTags()); $password = new Input(); $password->setName('password'); $password->setRequired(true); $password->setAllowEmpty(false); $password->getFilterChain()->attach(new StringTrim())->attach(new StripTags()); $password->getValidatorChain()->attach($serviceLocator->get('UghAuthentication\\Authentication\\Validator\\Authentication')); $inputFilter = new InputFilter(); $inputFilter->add($username); $inputFilter->add($password); return $inputFilter; }
public function __construct() { $translator = new \Zend\I18n\Translator\Translator(); $translator->addTranslationFile('phparray', './module/Contenuti/language/es.php'); $translatorMvc = new \Zend\Mvc\I18n\Translator($translator); \Zend\Validator\AbstractValidator::setDefaultTranslator($translatorMvc); $titolo = new Input('titolo'); $titolo->setRequired(true); $titolo->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); $titolo->getValidatorChain()->addValidator(new StringLength($this->opcionesStringLenght))->addValidator(new Alnum($this->opcionesAlnum)); $this->add($titolo); $this->add(array('name' => 'posterlab', 'required' => true, 'validators' => array(array('name' => 'Int')))); $this->add(array('name' => 'tipo', 'required' => true, 'validators' => array(array('name' => 'Int')))); $background = new FileInput('background'); $background->setRequired(true); $background->getFilterChain()->attach(new RenameUpload(array('target' => './httpdocs/immagine/contenuto/contenuto_', 'use_upload_extension' => true, 'randomize' => true))); $background->getValidatorChain()->attach(new Size(array('max' => substr(ini_get('upload_max_filesize'), 0, -1) . 'MB'))); $this->add($background); }
public function __construct() { /* email filters and validators */ $usuario = new Input('username'); $usuario->setRequired(true); // Filters $usuario->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); // Validators $usuario->getValidatorChain()->attach(new Validator\NotEmpty()); $this->add($usuario); /* clave filters and validators */ $clave = new Input('password'); $clave->setRequired(true); // Filters $clave->getFilterChain()->attachByName('StripTags')->attachByName('StringTrim'); // Validators $clave->getValidatorChain()->attach(new Validator\StringLength(array('min' => 4, 'max' => 14, 'messages' => array(Validator\StringLength::TOO_SHORT => "La clave debe tener mÃnimo 6 caracteres", Validator\StringLength::TOO_LONG => "La clave debe tener máximo 14 caracteres"))))->attach(new I18nValidator\Alnum(array('allowWhiteSpace' => false))); $this->add($clave); }
/** * {@inheritdoc} */ public function init() { // Chave Primária $input = new Input('id'); $input->getFilterChain()->attach(new Filter\ToInt()); $this->add($input); // Tipo $input = new Input('type'); $input->getValidatorChain()->attach(new Validator\InArray(array('haystack' => array_keys((new AccountType())->getDefinition())))); $this->add($input); // Acúmulo de Conta $input = new Input('accumulate'); $input->getValidatorChain()->attach(new Validator\InArray(array('haystack' => array_keys((new BooleanType())->getDefinition())))); $this->add($input); // Nome $this->add(new Input('name')); // Descrição $this->add(new Input('description')); }