@@ -255,6 +255,66 @@ describe('createForm', () => {
255255 } )
256256 . then ( done ) ;
257257 } ) ;
258+
259+ it ( 'is false for invalid arrays' , async done => {
260+ const validationSchema = yup
261+ . array ( )
262+ . of ( yup . object ( ) . shape ( { x : yup . string ( ) . required ( ) } ) . required ( ) ) ;
263+ const initialValues = [ { x : '' } ] ;
264+ const formInstance = getInstance ( { validationSchema, initialValues} ) ;
265+
266+ formInstance
267+ . handleSubmit ( )
268+ . then ( ( ) => subscribeOnce ( formInstance . isValid ) )
269+ . then ( isValid => expect ( isValid ) . toBe ( false ) )
270+ . then ( done ) ;
271+ } ) ;
272+
273+ it ( 'is true for valid arrays' , async done => {
274+ const validationSchema = yup
275+ . array ( )
276+ . of ( yup . object ( ) . shape ( { x : yup . string ( ) . required ( ) } ) . required ( ) ) ;
277+ const initialValues = [ { x : 'foo' } ] ;
278+ const formInstance = getInstance ( { validationSchema, initialValues} ) ;
279+
280+ formInstance
281+ . handleSubmit ( )
282+ . then ( ( ) => subscribeOnce ( formInstance . isValid ) )
283+ . then ( isValid => expect ( isValid ) . toBe ( true ) )
284+ . then ( done ) ;
285+ } ) ;
286+
287+ it ( 'is false for invalid nested arrays' , async done => {
288+ const validationSchema = yup . object ( ) . shape ( {
289+ xs : yup
290+ . array ( )
291+ . of ( yup . object ( ) . shape ( { x : yup . string ( ) . required ( ) } ) . required ( ) ) ,
292+ } ) ;
293+ const initialValues = { xs : [ { x : '' } ] } ;
294+ const formInstance = getInstance ( { validationSchema, initialValues} ) ;
295+
296+ formInstance
297+ . handleSubmit ( )
298+ . then ( ( ) => subscribeOnce ( formInstance . isValid ) )
299+ . then ( isValid => expect ( isValid ) . toBe ( false ) )
300+ . then ( done ) ;
301+ } ) ;
302+
303+ it ( 'is true for valid nested arrays' , async done => {
304+ const validationSchema = yup . object ( ) . shape ( {
305+ xs : yup
306+ . array ( )
307+ . of ( yup . object ( ) . shape ( { x : yup . string ( ) . required ( ) } ) . required ( ) ) ,
308+ } ) ;
309+ const initialValues = { xs : [ { x : 'bar' } ] } ;
310+ const formInstance = getInstance ( { validationSchema, initialValues} ) ;
311+
312+ formInstance
313+ . handleSubmit ( )
314+ . then ( ( ) => subscribeOnce ( formInstance . isValid ) )
315+ . then ( isValid => expect ( isValid ) . toBe ( true ) )
316+ . then ( done ) ;
317+ } ) ;
258318 } ) ;
259319
260320 describe ( 'handleReset' , ( ) => {
0 commit comments