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 1- import { AbstractRule } from './abstract-rule' ;
2- import { Regex } from './regex' ;
1+ import { AbstractString } from './abstract-string' ;
32
4- export class Isin extends AbstractRule {
3+ export class Isin extends AbstractString {
54
65 /**
7- * Validate.
6+ * Validate string .
87 */
9- public validate ( input : any ) : boolean {
10- if ( ! new Regex ( / ^ [ A - Z ] { 2 } [ 0 - 9 A - Z ] { 9 } [ 0 - 9 ] $ / ) . validate ( input ) ) {
8+ protected validateString ( input : string ) : boolean {
9+ if ( ! / ^ [ A - Z ] { 2 } [ 0 - 9 A - Z ] { 9 } [ 0 - 9 ] $ / . test ( input ) ) {
1110 return false ;
1211 }
1312
14- const inputString : string = String ( input ) ;
15- const checksumStr : string = inputString . replace ( / [ A - Z ] / g, ( c : string ) : string => parseInt ( c , 36 ) . toString ( ) ) ;
13+ const checksumStr : string = input . replace ( / [ A - Z ] / g, ( c : string ) : string => parseInt ( c , 36 ) . toString ( ) ) ;
1614
1715 let sum : number = 0 ;
1816 let digit : string ;
@@ -33,7 +31,7 @@ export class Isin extends AbstractRule {
3331 shouldDouble = ! shouldDouble ;
3432 }
3533
36- return parseInt ( inputString . substr ( inputString . length - 1 ) , 10 ) === ( 10000 - sum ) % 10 ;
34+ return parseInt ( input . substr ( input . length - 1 ) , 10 ) === ( 10000 - sum ) % 10 ;
3735 }
3836}
3937
You can’t perform that action at this time.
0 commit comments