All files bi.validator.ts

83.33% Statements 5/6
100% Branches 2/2
50% Functions 1/2
75% Lines 3/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 131x     1x   5x              
import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from "class-validator";
 
@ValidatorConstraint({name:'AngolanBIValidator', async: false})
export class AngolanBIValidator implements ValidatorConstraintInterface {
    validate(value: any): Promise<boolean> | boolean {
        return typeof value === 'string' && /^\d{9}[A-Z]{2}\d{3}$/.test(value);
    }
    defaultMessage(args: ValidationArguments): string {
          return `${args.property} deve ser um BI angolano vĂ¡lido (Ex: 005928773LA049)`;
 
    }
 
}