Mejora validacion correo usuario

parent 0fbdf36b
......@@ -313,6 +313,18 @@ class UtilidadesController extends AbstractController {
$em = $this->getDoctrine()->getManager('default');
$idAsistente = $user->getUadId();
//validacion mail
if(Utiles::validarCorreo($email) == 0){
$log->debug("El correo ingresado no es válido...");
$json->setData(array('errors' => "El correo ingresado no es válido."));
$json->setStatusCode(JsonResponse::HTTP_BAD_REQUEST);
return $json;
}
//validacion rut
if ($idUsuario == "" || $nombre == "" || $rut == "" || $mail == "" ) {
$log->debug("Los datos ingresados no pueden estar vacios...");
$json->setData(array('errors' => "Los datos ingresados no pueden estar vacíos."));
......
......@@ -221,5 +221,18 @@ class Utiles {
return $str_valor;
}
/**
* FUNCIÓN PARA VALIDAR CORREO ELECTRÓNICO, MEDIANTE USO DE EXPRESIÓN REGULAR.
* @param type $email
* @return int
*/
public static function validarCorreo($email=""){
$expresion_regular_correo="/^[A-Z0-9._%+-]+@([A-Z0-9-]+\.)+[A-Z]{2,4}$/i";
if(preg_match($expresion_regular_correo, $email)){
return 1;
}else{
return 0;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment