Closed vonagam closed 1 year ago
Thanks for the contribution. Can you add an unit test for this new option?
Added a test with expected behavior.
Thanks for the test.
The type should be updated as well: https://github.com/react-hook-form/resolvers/blob/master/vest/src/types.ts#L12
The linked line is one that I made note of. It is unused and can be removed, but this is a breaking change, I assume.
There is no change in types, because all arguments are the same. Currently vest suite signature is undefined. It is simply ReturnType<typeof Vest.create>
so can be any function (even though implementation expects that first argument is field values, it is not expressed in types currently).
Ok, if it is allowed then it makes sense to type the expected call signature of a vest suite. I think this one is reasonable:
(values: TValues, names?: FieldName<TValues>[], context?: TContext) => void
So pass names as the second argument (such signature is shown many times in Vest documentation, mostly for passing to only
) and a user supplied validation context as the third argument.
Thank you for your contributions! This Pull Request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Best, RHF Team ❤️
Any thoughts?
I tried your code locally, everything seems to work as expected without any breaking changes. @bluebill1049 Any thoughts? I'm about to merge this PR
Sounds good to me 👍 @jorisre
There is a PR here as well: https://github.com/react-hook-form/react-hook-form/pull/10590
FYI @bluebill1049 I merged but I'll release later with others fixes
:tada: This PR is included in version 3.3.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
React Hook Form has a way to signal to a resolver for which fields validations were requested (
options.names
/options.fields
) and Vest has a way to skip unrequested validations (only
/skip
/include
). But currently that names information gets discarded and Vest cannot utilize that functionality. I think it makes sense to pass names as a second argument.Note:
vestResolver
has a second argument which is and never was utilized, other adapters do not have such thing. I think it should be put on note somewhere for removal in next major release.