feat: agregar validacion de entrada con class-validator - #47
Open
anidroid1184 wants to merge 2 commits into
Open
feat: agregar validacion de entrada con class-validator#47anidroid1184 wants to merge 2 commits into
anidroid1184 wants to merge 2 commits into
Conversation
- Agrega ValidationPipe global con whitelist, forbidNonWhitelisted y exceptionFactory personalizada - Define RegisterDto y LoginDto con decoradores de validacion (@isemail, @minlength, @isin, @IsOptional) - Remueve guards manuales if (!email || !password) reemplazados por validacion automatica - Agrega tests unitarios al DTO con plainToInstance + validate
|
Someone is attempting to deploy a commit to the josueazc's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
@josueazc please review the PR |
Contributor
|
resolve conflicts before continuing. |
Author
|
@josueazc only falls the vercel check. |
Contributor
|
resolve conflicts before continuing. apps/api/src/auth/auth.service.ts |
Author
|
@josueazc sure, I'll review that |
Author
|
@josueazc conflicts resolved and merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Qué cambia
Se habilita validación automática de entrada en la API de NestJS usando
class-validatoryclass-transformer. Antes los payloads llegaban al servicio sin validar — ahora elValidationPipeglobal rechaza cualquier body inválido con un 400 estructurado antes de que toque la lógica de negocio.Archivos modificados:
apps/api/src/bootstrap.ts— ValidationPipe global conwhitelist: true,forbidNonWhitelisted: true, yexceptionFactoryque produce errores descriptivos por campo.apps/api/src/auth/dto/auth.dto.ts—RegisterDtoyLoginDtodecorados con@IsEmail,@MinLength(8),@IsIn(['usuario','partido','tse']),@IsOptional, etc.apps/api/src/auth/auth.service.ts— TiposRegisterInput/LoginInputmovidos al DTO, guards manualesif (!email || !password)eliminados, firma de métodos actualizada aRegisterDto/LoginDto.apps/api/src/auth/auth.dto.spec.ts— 6 tests unitarios conplainToInstance+validatecubriendo email inválido, password corta, perspectiva inválida, campos desconocidos, y payloads válidos (usuario y partido).Closes #23
Por qué
Los payloads de registro y login llegaban sin validación automática al servicio. Un llamado con email inválido, password vacía, o campos extras no era rechazado por el framework — dependía de guards manuales dispersos. NestJS ofrece
ValidationPipe+class-validatorque resuelve esto a nivel framework con cero código repetitivo por endpoint.Checklist
feat/fix/docs/chore)Nota: El spec bonds.service.spec.ts tiene un test que falla preexistente (paymentMethods faltante en el evento esperado de auditoría) — no relacionado con este cambio.