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 = {
33 restoreMocks : true ,
44 testMatch : [ '**/__tests__/**/*.+(js|jsx|ts|tsx)' ] ,
55 transformIgnorePatterns : [ '[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$' ] ,
6+ testPathIgnorePatterns : [ '/__fixtures__/' , '/\\.' ] ,
67 moduleNameMapper : {
78 '^@hookform/resolvers$' : '<rootDir>/src' ,
89 } ,
Original file line number Diff line number Diff line change @@ -290,4 +290,22 @@ describe('validateWithSchema', () => {
290290 errors : { name : { message : 'Email or name are required' , type : 'name' } } ,
291291 } ) ;
292292 } ) ;
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+ } ) ;
293311} ) ;
Original file line number Diff line number Diff line change @@ -82,7 +82,11 @@ export const yupResolver = <TFieldValues extends FieldValues>(
8282 } ) ,
8383 errors : { } ,
8484 } ;
85- } catch ( e ) {
85+ } catch ( e : any ) {
86+ if ( ! e . inner ) {
87+ throw e ;
88+ }
89+
8690 const parsedErrors = parseErrorSchema ( e , validateAllFieldCriteria ) ;
8791 return {
8892 values : { } ,
You can’t perform that action at this time.
0 commit comments