Skip to content

Commit

Permalink
v4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak committed Mar 3, 2024
1 parent 52f6da5 commit 8194d15
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remix-hook-form",
"version": "4.1.0",
"version": "4.2.0",
"description": "Utility wrapper around react-hook-form for use with Remix.run",
"type": "module",
"main": "./dist/index.cjs",
Expand Down Expand Up @@ -68,7 +68,7 @@
"@remix-run/react": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.48.2"
"react-hook-form": "^7.51.0"
},
"readme": "https://github.com/Code-Forge-Net/remix-hook-form#readme",
"devDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions src/utilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,17 @@ export const isGet = (request: Pick<Request, "method">) =>
* @async
* @param {Request} request - An object that represents an HTTP request.
* @param validator - A function that resolves the schema.
* @param {boolean} [preserveStringified=false] - Whether to preserve stringified values or try to convert them
* @returns A Promise that resolves to an object containing the validated data or any errors that occurred during validation.
*/
export const getValidatedFormData = async <T extends FieldValues>(
request: Request,
resolver: Resolver<T>,
preserveStringified = false,
) => {
const data = isGet(request)
? getFormDataFromSearchParams(request)
: await parseFormData<T>(request);
? getFormDataFromSearchParams(request, preserveStringified)
: await parseFormData<T>(request, preserveStringified);

const validatedOutput = await validateFormData<T>(data, resolver);
return { ...validatedOutput, receivedValues: data };
Expand Down

0 comments on commit 8194d15

Please sign in to comment.