Skip to content

Commit

Permalink
[ADD] cedula validation
Browse files Browse the repository at this point in the history
  • Loading branch information
marluanespiritusanto committed Aug 25, 2021
1 parent 4445a8a commit a5ea4de
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/modules/contributors/guards/rnc-validator.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ export class RncValidatorGuard implements CanActivate {

async canActivate(context: ExecutionContext): Promise<boolean> {
const RNC_REQUIRED_LENGTH = 9;
const CEDULA_REQUIRED_LENGTH = 11;
const request: Request = context.switchToHttp().getRequest();

const { rnc } = request.params;

if (rnc.length !== RNC_REQUIRED_LENGTH) {
if (
rnc.length !== RNC_REQUIRED_LENGTH &&
rnc.length !== CEDULA_REQUIRED_LENGTH
) {
throw new BadRequestException({
valid: false,
message: 'Invalid RNC',
Expand Down

0 comments on commit a5ea4de

Please sign in to comment.