コード例 #1
0
ファイル: UsuarioCtrl.php プロジェクト: virtuagora/virtuagora
 public function modificar()
 {
     $vdt = new Validate\Validator();
     $vdt->addRule('nombre', new Validate\Rule\Alpha(array(' ')))->addRule('nombre', new Validate\Rule\MinLength(1))->addRule('nombre', new Validate\Rule\MaxLength(32))->addRule('apellido', new Validate\Rule\Alpha(array(' ')))->addRule('apellido', new Validate\Rule\MinLength(1))->addRule('apellido', new Validate\Rule\MaxLength(32))->addRule('url', new Validate\Rule\URL())->addRule('email', new Validate\Rule\Email())->addRule('telefono', new Validate\Rule\Telephone())->addOptional('url')->addOptional('email')->addOptional('telefono')->addFilter('url', FilterFactory::emptyToNull())->addFilter('telefono', FilterFactory::emptyToNull());
     $req = $this->request;
     if (!$vdt->validate($req->post())) {
         throw new TurnbackException($vdt->getErrors());
     }
     $usuario = $this->session->getUser();
     $usuario->nombre = $vdt->getData('nombre');
     $usuario->apellido = $vdt->getData('apellido');
     $usuario->save();
     $contacto = $usuario->contacto ?: new Contacto();
     $contacto->email = $vdt->getData('email');
     $contacto->web = $vdt->getData('url');
     $contacto->telefono = $vdt->getData('telefono');
     $contacto->contactable()->associate($usuario);
     $contacto->save();
     $this->flash('success', 'Sus datos fueron modificados exitosamente.');
     $this->redirect($this->request->getReferrer());
 }
コード例 #2
0
ファイル: OrganismoCtrl.php プロジェクト: DiegoVI/virtuagora
 private function validarOrganismo($data)
 {
     $vdt = new Validate\Validator();
     $vdt->addRule('nombre', new Validate\Rule\Alpha(array(' ')))->addRule('nombre', new Validate\Rule\MinLength(2))->addRule('nombre', new Validate\Rule\MaxLength(64))->addRule('descripcion', new Validate\Rule\MaxLength(512))->addRule('cupo', new Validate\Rule\NumNatural())->addRule('cupo', new Validate\Rule\NumMin(1))->addRule('cupo', new Validate\Rule\NumMax(128))->addRule('url', new Validate\Rule\URL())->addRule('email', new Validate\Rule\Email())->addRule('telefono', new Validate\Rule\Telephone())->addOptional('url')->addOptional('email')->addOptional('telefono')->addFilter('url', FilterFactory::emptyToNull())->addFilter('email', FilterFactory::emptyToNull())->addFilter('telefono', FilterFactory::emptyToNull());
     if (!$vdt->validate($data)) {
         throw new TurnbackException($vdt->getErrors());
     }
     return $vdt;
 }
コード例 #3
0
 private function validarPropuesta($data)
 {
     $vdt = new Validate\Validator();
     $vdt->addRule('titulo', new Validate\Rule\MinLength(8))->addRule('titulo', new Validate\Rule\MaxLength(128))->addRule('categoria', new Validate\Rule\NumNatural())->addRule('categoria', new Validate\Rule\Exists('categorias'))->addRule('referido', new Validate\Rule\NumNatural())->addRule('cuerpo', new Validate\Rule\MinLength(8))->addRule('cuerpo', new Validate\Rule\MaxLength(8192))->addFilter('cuerpo', FilterFactory::escapeHTML())->addFilter('referido', FilterFactory::emptyToNull())->addFilter('tags', FilterFactory::explode(','))->addOptional('referido');
     if (!$vdt->validate($data)) {
         throw new TurnbackException($vdt->getErrors());
     }
     return $vdt;
 }
コード例 #4
0
ファイル: PartidoCtrl.php プロジェクト: DiegoVI/virtuagora
 private function validarPartido($data)
 {
     $vdt = new Validate\Validator();
     $vdt->addRule('nombre', new Validate\Rule\Alpha(array(' ')))->addRule('nombre', new Validate\Rule\MinLength(2))->addRule('nombre', new Validate\Rule\MaxLength(64))->addRule('acronimo', new Validate\Rule\Alpha())->addRule('acronimo', new Validate\Rule\MinLength(2))->addRule('acronimo', new Validate\Rule\MaxLength(8))->addRule('descripcion', new Validate\Rule\MinLength(4))->addRule('descripcion', new Validate\Rule\MaxLength(512))->addRule('fundador', new Validate\Rule\Alpha(array(' ')))->addRule('fundador', new Validate\Rule\MaxLength(32))->addRule('fecha', new Validate\Rule\Date())->addRule('url', new Validate\Rule\URL())->addRule('email', new Validate\Rule\Email())->addRule('telefono', new Validate\Rule\Telephone())->addOptional('fundador')->addOptional('fecha')->addOptional('url')->addOptional('email')->addOptional('telefono')->addFilter('fundador', FilterFactory::emptyToNull())->addFilter('fecha', FilterFactory::emptyToNull())->addFilter('url', FilterFactory::emptyToNull())->addFilter('email', FilterFactory::emptyToNull())->addFilter('telefono', FilterFactory::emptyToNull());
     if (!$vdt->validate($data)) {
         throw new TurnbackException($vdt->getErrors());
     }
     return $vdt;
 }