This repository was archived by the owner on Oct 20, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,20 +9,17 @@ export abstract class AbstractCalculation extends AbstractRule {
99 const c : string = String ( input ) . replace ( / [ ^ \d ] / g, '' ) ;
1010 const length : number = this . getLength ( ) ;
1111
12- if ( c . length !== length || RegExp ( `${ Number ( c [ 0 ] ) } {${ length } }` ) . test ( c ) ) {
12+ if ( ! c || ( length > 0 && ( c . length !== length || RegExp ( `${ Number ( c [ 0 ] ) } {${ length } }` ) . test ( c ) ) ) ) {
1313 return false ;
1414 }
1515
1616 return this . validateCalculation ( c ) ;
17-
1817 }
1918
2019 /**
2120 * Get Length.
2221 */
23- protected getLength ( ) : number {
24- return 11 ;
25- }
22+ protected abstract getLength ( ) : number ;
2623
2724 /**
2825 * Validate Calculation.
Original file line number Diff line number Diff line change @@ -2,6 +2,13 @@ import { AbstractCalculation } from './abstract-calculation';
22
33export class Cnh extends AbstractCalculation {
44
5+ /**
6+ * Get Length.
7+ */
8+ protected getLength ( ) : number {
9+ return 11 ;
10+ }
11+
512 /**
613 * Validate Calculation.
714 */
Original file line number Diff line number Diff line change @@ -2,6 +2,13 @@ import { AbstractCalculation } from './abstract-calculation';
22
33export class Cpf extends AbstractCalculation {
44
5+ /**
6+ * Get Length.
7+ */
8+ protected getLength ( ) : number {
9+ return 11 ;
10+ }
11+
512 /**
613 * Validate Calculation.
714 */
Original file line number Diff line number Diff line change @@ -3,6 +3,13 @@ import { AbstractCalculation } from './abstract-calculation';
33
44export class Pesel extends AbstractCalculation {
55
6+ /**
7+ * Get Length.
8+ */
9+ protected getLength ( ) : number {
10+ return 11 ;
11+ }
12+
613 /**
714 * Validate Calculation.
815 */
Original file line number Diff line number Diff line change @@ -2,6 +2,13 @@ import { AbstractCalculation } from './abstract-calculation';
22
33export class Pis extends AbstractCalculation {
44
5+ /**
6+ * Get Length.
7+ */
8+ protected getLength ( ) : number {
9+ return 11 ;
10+ }
11+
512 /**
613 * Validate Calculation.
714 */
You can’t perform that action at this time.
0 commit comments