@@ -120,11 +120,6 @@ describe("Test getRuleFromSchema method", () => {
120120
121121 const v = new Validator ( ) ;
122122
123- it ( "should convert string shorthand" , ( ) => {
124- const res = v . getRuleFromSchema ( "string" ) ;
125- expect ( res . schema ) . toEqual ( { type : "string" } ) ;
126- } ) ;
127-
128123 it ( "should convert array to multi rule" , ( ) => {
129124 const res = v . getRuleFromSchema ( [
130125 "string" ,
@@ -172,6 +167,25 @@ describe("Test getRuleFromSchema method", () => {
172167 v . compile ( schema ) ;
173168 } ) . toThrowError ( "Invalid 's' type in validator schema." ) ;
174169 } ) ;
170+
171+ describe ( "Test string shorthard rules" , ( ) => {
172+
173+ it ( "should convert only type" , ( ) => {
174+ const res = v . getRuleFromSchema ( "string" ) ;
175+ expect ( res . schema ) . toEqual ( { type : "string" } ) ;
176+ } ) ;
177+
178+ it ( "should convert with properties" , ( ) => {
179+ const res = v . getRuleFromSchema ( "string|min:3 | max : 10| trim" ) ;
180+ expect ( res . schema ) . toEqual ( { type : "string" , min : 3 , max : 10 , trim : true } ) ;
181+ } ) ;
182+
183+ it ( "should convert with disabled properties" , ( ) => {
184+ const res = v . getRuleFromSchema ( "string|no-empty|trim:true|alpha:false|some:1234kg" ) ;
185+ expect ( res . schema ) . toEqual ( { type : "string" , empty : false , alpha : false , trim : true , some : "1234kg" } ) ;
186+ } ) ;
187+
188+ } ) ;
175189} ) ;
176190
177191describe ( "Test compile (integration test)" , ( ) => {
0 commit comments