File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -105,13 +105,13 @@ export function validateIotaName(
105105 if ( ! allowSubnames && parts . length > 2 ) {
106106 return 'No subnames allowed' ;
107107 }
108- if ( ! NAME_DOT_REGEX . test ( name ) ) {
109- return 'Invalid characters. Only a-z, 0-9, and hyphens (not at the beginning or end) are allowed' ;
110- }
111108 for ( const part of parts . slice ( 0 , - 1 ) ) {
112109 if ( part . length < minLength || part . length > maxLength ) {
113110 return `Name must be ${ minLength } -${ maxLength } characters long` ;
114111 }
115112 }
113+ if ( ! NAME_DOT_REGEX . test ( name ) ) {
114+ return 'Invalid characters. Only a-z, 0-9, and hyphens (not at the beginning or end) are allowed' ;
115+ }
116116 return null ;
117117}
Original file line number Diff line number Diff line change @@ -105,8 +105,15 @@ describe('Name validation with error', () => {
105105 } ) ;
106106
107107 test ( 'should check the length' , ( ) => {
108- expect ( validateIotaName ( 'name.iota' , 10 ) ) . not . toBeNull ( ) ;
109- expect ( validateIotaName ( 'nameeeeeeeeeee.iota' , 3 , 10 ) ) . not . toBeNull ( ) ;
108+ expect ( validateIotaName ( 'name.iota' , 10 ) ) . toEqual ( 'Name must be 10-64 characters long' ) ;
109+ expect ( validateIotaName ( 'nameeeeeeeeeee.iota' , 3 , 10 ) ) . toEqual (
110+ 'Name must be 3-10 characters long' ,
111+ ) ;
112+ expect (
113+ validateIotaName (
114+ 'veryveryveryveryveryveryveryveryveryveryveryverylongnamewithmorethan64chars.iota' ,
115+ ) ,
116+ ) . toEqual ( 'Name must be 3-64 characters long' ) ;
110117 } ) ;
111118
112119 test ( 'should check the subnames' , ( ) => {
You can’t perform that action at this time.
0 commit comments