11import { toNestErrors , validateFieldsNatively } from '@hookform/resolvers' ;
22import { StandardSchemaV1 } from '@standard-schema/spec' ;
3+ import { getDotPath } from '@standard-schema/utils' ;
34import { FieldError , FieldValues , Resolver } from 'react-hook-form' ;
45
56function parseIssues (
@@ -10,7 +11,7 @@ function parseIssues(
1011
1112 for ( let i = 0 ; i < issues . length ; i ++ ) {
1213 const error = issues [ i ] ;
13- const path = error . path ?. join ( '.' ) ;
14+ const path = getDotPath ( error ) ;
1415
1516 if ( path ) {
1617 if ( ! errors [ path ] ) {
@@ -52,15 +53,14 @@ function parseIssues(
5253 * ```
5354 */
5455export function standardSchemaResolver <
55- TFieldValues extends FieldValues ,
56- Schema extends StandardSchemaV1 < TFieldValues , any > ,
56+ Schema extends StandardSchemaV1 < FieldValues > ,
5757> (
5858 schema : Schema ,
5959 resolverOptions : {
6060 raw ?: boolean ;
6161 } = { } ,
62- ) : Resolver < NonNullable < ( typeof schema ) [ '~standard' ] [ 'types' ] > [ 'output' ] > {
63- return async ( values : TFieldValues , _ , options ) => {
62+ ) : Resolver < StandardSchemaV1 . InferOutput < Schema > > {
63+ return async ( values , _ , options ) => {
6464 let result = schema [ '~standard' ] . validate ( values ) ;
6565 if ( result instanceof Promise ) {
6666 result = await result ;
0 commit comments