File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 digits ,
1919 email ,
2020 fourDigitsCode ,
21+ hexadecimal ,
2122 macAddress ,
2223 phone ,
2324 sixDigitsCode ,
@@ -558,4 +559,26 @@ describe('@regex', () => {
558559 expect ( url . test ( string ) ) . toBe ( result ) ) ,
559560 )
560561 } )
562+
563+ describe ( 'hexadecimal' , ( ) => {
564+ ; [
565+ [ asciiLetters , false ] ,
566+ [ asciiLowercase , false ] ,
567+ [ asciiUppercase , false ] ,
568+ [ digitsTest , true ] ,
569+ [ emailTest , false ] ,
570+ [ octdigits , true ] ,
571+ [ fourDigitsTest , true ] ,
572+ [ printable , false ] ,
573+ [ phoneTest , false ] ,
574+ [ sixDigitsCodeTest , true ] ,
575+ [ punctuation , false ] ,
576+ [ whitespace , false ] ,
577+ [ cronTest , false ] ,
578+ [ hexdigits , true ] ,
579+ ] . forEach ( ( [ string , result ] ) =>
580+ it ( `should match regex ${ string } to be ${ result } ` , ( ) =>
581+ expect ( hexadecimal . test ( string ) ) . toBe ( result ) ) ,
582+ )
583+ } )
561584} )
Original file line number Diff line number Diff line change @@ -24,3 +24,4 @@ export const phone = /^\+[0-9]*/
2424export const spaces = / ^ \s * $ /
2525export const sixDigitsCode = / ^ [ 0 - 9 ] { 6 } $ /
2626export const url = / ^ ( h t t p : \/ \/ w w w \. | h t t p s : \/ \/ w w w \. | h t t p : \/ \/ | h t t p s : \/ \/ ) ? [ a - z 0 - 9 ] + ( [ - . ] { 1 } [ a - z 0 - 9 ] + ) * \. [ a - z ] { 2 , 5 } ( : [ 0 - 9 ] { 1 , 5 } ) ? ( \/ .* ) ? $ /
27+ export const hexadecimal = / ^ [ 0 - 9 a - f A - F ] + $ /
You can’t perform that action at this time.
0 commit comments