Lançado Adianti Framework 7.6!
Clique aqui para saber mais
menu

Adianti Solutions

API

Adianti, Framework, PHP, MVC, Active record, Front controller, IDE, RAD, Web, multiplataforma, geração de código, desenvolvimento rápido, relatórios, formulários, listagens, datagrids, gráficos, banco de dados, padrões de projeto, design patterns API do Adianti Framework.
API Docs
code
Selecione a classe

Source for file TStrippedTextMaxLengthValidator.php

Documentation is available at TStrippedTextMaxLengthValidator.php

  1. <?php
  2. namespace Adianti\Validator;
  3.  
  4. use Adianti\Validator\TFieldValidator;
  5. use Adianti\Core\AdiantiCoreTranslator;
  6. use Exception;
  7.  
  8. /**
  9.  * Maximum stripped text length validation
  10.  *
  11.  * @version    7.4
  12.  * @package    validator
  13.  * @author     Pablo Dall'Oglio
  14.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  15.  * @license    http://www.adianti.com.br/framework-license
  16.  */
  17. {
  18.     /**
  19.      * Validate a given value
  20.      * @param $label Identifies the value to be validated in case of exception
  21.      * @param $value Value to be validated
  22.      * @param $parameters aditional parameters for validation (min value)
  23.      */
  24.     public function validate($label$value$parameters NULL)
  25.     {
  26.         $maxvalue $parameters[0];
  27.  
  28.         $value preg_replace('/(<p><br><\/p>)/i'' '$value);
  29.         $value preg_replace('/(<([^>]+)>)/i'''$value);
  30.         $value preg_replace('/(&nbsp;)/i'' '$value);
  31.         
  32.         $value strlen($value);
  33.         
  34.         if ($value $maxvalue)
  35.         {
  36.             throw new Exception(AdiantiCoreTranslator::translate('The field ^1 can not be greater than ^2 characters'$label$maxvalue));
  37.         }
  38.     }
  39. }