(I post this in security, but I'm not shure)
I've a problem, and that is that Phalcon\Validation
doesn't works in one part of my app; in the other hand, it works perfectly in the login.
LoginController.php
$this->view->disable();
$request = $this->request;
if ($request->isPost() === true)
{
$response = new Response();
$validacion = new Validation();
$resultado = false;
$validacion->add("usuario", new Regex(
array(
'pattern' => "/^[a-zA-Z0-9]+$/",
'cancelOnFail' => true
)
));
$validacion->add("contrasena", new Regex(
array(
'pattern' => "/.[^\s]./",
'cancelOnFail' => true
)
));
if ($validacion->validate($request->getPost()))
{
// Validates the user.
}
$response->setJsonContent(array('respuesta' => $resultado));
return $response;
}
ParteController.php
$this->view->disable();
$request = $this->request;
if ($request->isPost() === true)
{
$this->view->disable();
$response = new Response();
$validacion = new Validation();
$resultado = false;
$validacion->add("conductasElegidas", new Regex(
array(
// No matter what regex I put, it will validate everything ok. My test string for this post var is "1234"
'pattern' => "/^abc$/",
'cancelOnFail' => true
)
));
// Always happens.
if ($validacion->validate($request->getPost()))
{
$resultado = true;
}
$response->setJsonContent(array('respuesta' => $resultado));
return $response;
}