File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module.exports = {
3
3
restoreMocks : true ,
4
4
testMatch : [ '**/__tests__/**/*.+(js|jsx|ts|tsx)' ] ,
5
5
transformIgnorePatterns : [ '[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$' ] ,
6
+ testPathIgnorePatterns : [ '/__fixtures__/' , '/\\.' ] ,
6
7
moduleNameMapper : {
7
8
'^@hookform/resolvers$' : '<rootDir>/src' ,
8
9
} ,
Original file line number Diff line number Diff line change @@ -290,4 +290,22 @@ describe('validateWithSchema', () => {
290
290
errors : { name : { message : 'Email or name are required' , type : 'name' } } ,
291
291
} ) ;
292
292
} ) ;
293
+
294
+ it ( 'should throw an error without inner property' , ( done ) => {
295
+ const schemaWithWhen = yup . object ( {
296
+ name : yup . string ( ) . required ( ) ,
297
+ value : yup . string ( ) . when ( 'name' , {
298
+ is : 'test' ,
299
+ then : yup . number ( ) . required ( ) ,
300
+ } ) ,
301
+ } ) ;
302
+
303
+ // @ts -expect-error
304
+ yupResolver ( schemaWithWhen ) ( { name : 'test' , value : '' } ) . catch ( ( e ) => {
305
+ expect ( e ) . toMatchInlineSnapshot (
306
+ `[TypeError: You cannot \`concat()\` schema's of different types: string and number]` ,
307
+ ) ;
308
+ done ( ) ;
309
+ } ) ;
310
+ } ) ;
293
311
} ) ;
Original file line number Diff line number Diff line change @@ -82,7 +82,11 @@ export const yupResolver = <TFieldValues extends FieldValues>(
82
82
} ) ,
83
83
errors : { } ,
84
84
} ;
85
- } catch ( e ) {
85
+ } catch ( e : any ) {
86
+ if ( ! e . inner ) {
87
+ throw e ;
88
+ }
89
+
86
90
const parsedErrors = parseErrorSchema ( e , validateAllFieldCriteria ) ;
87
91
return {
88
92
values : { } ,
You can’t perform that action at this time.
0 commit comments