File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -141,4 +141,31 @@ describe('isLength', () => {
141141 valid : [ '👩🦰👩👩👦👦🏳️🌈' , '⏩︎⏩︎⏪︎⏪︎⏭︎⏭︎⏮︎⏮︎' ] ,
142142 } ) ;
143143 } ) ;
144+
145+ it ( 'should return true if string exactly match min/max bounds' , ( ) => {
146+ test ( {
147+ validator : 'isLength' ,
148+ args : [ { min : 3 , max : 3 } ] ,
149+ valid : [ 'abc' , 'def' ] ,
150+ invalid : [ 'abcd' , 'efgh' ] ,
151+ } ) ;
152+ } ) ;
153+
154+ it ( 'should count emojis as single character' , ( ) => {
155+ test ( {
156+ validator : 'isLength' ,
157+ args : [ { min : 1 , max : 1 } ] ,
158+ valid : [ '🚀' , '🍕' , 'A' ] ,
159+ invalid : [ '🚀🚀' , '' ] ,
160+ } ) ;
161+ } ) ;
162+
163+ it ( 'should only allow strings with specific lengths from a list' , ( ) => {
164+ test ( {
165+ validator : 'isLength' ,
166+ args : [ { discreteLengths : [ 2 , 5 ] } ] ,
167+ valid : [ 'to' , 'hello' ] ,
168+ invalid : [ 'a' , 'cat' , 'lengthy' ] ,
169+ } ) ;
170+ } ) ;
144171} ) ;
You can’t perform that action at this time.
0 commit comments