Ejemplo n.º 1
0
 private function validarCampo($valorCampo, array $outrosCampos = array())
 {
     if (isset($outrosCampos['repetir']) && $outrosCampos['repetir'] == 'S') {
         if (empty($valorCampo)) {
             $this->error(self::MSG_DESPESA_REPETIR_QUANDO_REQUERIDA);
             return false;
         }
     } elseif (isset($outrosCampos['repetir']) && $outrosCampos['repetir'] == 'N') {
         if (!empty($valorCampo)) {
             $this->error(self::MSG_DESPESA_REPETIR_QUANDO_NAO_INFORMAR);
             return false;
         }
     }
     if (!empty($valorCampo)) {
         $stringLenght = new StringLength();
         $stringLenght->setMin('3');
         $stringLenght->setMax('3');
         $stringLenght->setEncoding("UTF-8");
         if (!$stringLenght->isValid($valorCampo)) {
             $this->error(self::MSG_DESPESA_REPETIR_QUANDO_VALOR_INVALIDO);
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * @return void
  */
 public function testDifferentEncodingWithValidator()
 {
     iconv_set_encoding('internal_encoding', 'UTF-8');
     $validator = new StringLength(2, 2, 'UTF-8');
     $this->assertEquals(true, $validator->isValid('ab'));
     $this->assertEquals('UTF-8', $validator->getEncoding());
     $validator->setEncoding('ISO-8859-1');
     $this->assertEquals('ISO-8859-1', $validator->getEncoding());
 }