File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @scaleway/regex ' : minor
3+ ---
4+
5+ Add alphanumdashunderscore regex
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
1717 alphanumdashdotsspaces ,
1818 alphanumdashorempty ,
1919 alphanumdashspaces ,
20+ alphanumdashunderscore ,
2021 alphanumdashunderscoredotsspacesparenthesis ,
2122 alphanumdots ,
2223 ascii ,
@@ -286,6 +287,28 @@ describe('@regex', () => {
286287 } )
287288 } )
288289
290+ describe ( 'alphanumdashunderscore' , ( ) => {
291+ test . each ( [
292+ [ alphanumdashText , true ] ,
293+ [ alphanumdashdotsText , false ] ,
294+ [ alphanumdashunderscoredotsparenthesisText , false ] ,
295+ [ asciiLetters , true ] ,
296+ [ asciiLowercase , true ] ,
297+ [ asciiUppercase , true ] ,
298+ [ digitsTest , true ] ,
299+ [ emailTest , false ] ,
300+ [ octdigits , true ] ,
301+ [ hexdigits , true ] ,
302+ [ printable , false ] ,
303+ [ punctuation , false ] ,
304+ [ whitespace , false ] ,
305+ [ cronTest , false ] ,
306+ [ macAddress1 , false ] ,
307+ ] ) ( 'should match regex %s to be %s' , ( string , expected ) => {
308+ expect ( alphanumdashunderscore . test ( string ) ) . toBe ( expected )
309+ } )
310+ } )
311+
289312 describe ( 'alphanumdashorempty' , ( ) => {
290313 test . each ( [
291314 [ alphanumdashText , true ] ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export const alphanumdash = /^[a-zA-Z0-9-]*$/
77export const alphanumdashdots = / ^ [ a - z A - Z 0 - 9 - .] * $ /
88export const alphanumdashdotsorempty = / ^ $ | ^ [ a - z A - Z 0 - 9 - .] * $ /
99export const alphanumdashdotsspaces = / ^ [ a - z A - Z 0 - 9 - .\s] * $ /
10+ export const alphanumdashunderscore = / ^ [ a - z A - Z 0 - 9 - _ ] * $ /
1011export const alphanumdashunderscoredotsspacesparenthesis =
1112 / ^ [ a - z A - Z 0 - 9 - _ .( ) \s ] * $ /
1213
You can’t perform that action at this time.
0 commit comments