-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`soft` versions now include a [typed error property `GenericError { issues?: GenericIssue[] }`](./src/lib.ts#L73), which is the error thrown by the validator. It is based on a Zod error, but you may type it as something else if your parser throws a different error type. This is helpful for type narrowing (ie. you don't have to type `(result.error as any).issues` to get to the issues). If you're not using Zod, to type the error property, pass it as the second generic type argument to `soft` methods. For example, `softForm<typeof myschema.parse, MyErrorType>(obj, myschema.parse)`. Note that you have to also manually type the parser if you want type its error differently.
- Loading branch information
Showing
7 changed files
with
500 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
# Changelog | ||
|
||
## 1.6.0 (2024-04-05) | ||
|
||
`soft` versions now include a [typed error property `GenericError { issues?: GenericIssue[] }`](./src/lib.ts#L73), which is the error thrown by the validator. It is based on a Zod error, but you may type it as something else if your parser throws a different error type. This is helpful for type narrowing (ie. you don't have to type `(result.error as any).issues` to get to the issues). | ||
|
||
If you're not using Zod, to type the error property, pass it as the second generic type argument to `soft` methods. For example, `softForm<typeof myschema.parse, MyErrorType>(obj, myschema.parse)`. Note that you have to also manually type the parser if you want type its error differently. | ||
|
||
## 1.5.2 (2024-04-03) | ||
|
||
- `soft` versions can now also return the parsed value if there was one returned but it did not pass the validation. This is useful when you want to show the user the parsed value in the form after a validation error. | ||
`soft` versions can now also return the parsed value if there was one returned but it did not pass the validation. This is useful when you want to show the user the parsed value in the form after a validation error. | ||
|
||
## 1.5.1 (2024-04-03) | ||
|
||
- Added missing export for `BodyguardFormConfig` interface | ||
Added missing export for `BodyguardFormConfig` interface | ||
|
||
## 1.5.0 (2024-02-20) | ||
|
||
### New Features | ||
|
||
- **File upload support in multipart forms.** `form()` and `softForm()` will return uploaded files as [File objects](https://developer.mozilla.org/en-US/docs/Web/API/File). | ||
**File upload support in multipart forms.** `form()` and `softForm()` will return uploaded files as [File objects](https://developer.mozilla.org/en-US/docs/Web/API/File). | ||
|
||
## 1.4.0 (2024-02-19) | ||
|
||
### Breaking Changes | ||
|
||
- The `error` returned from `soft*` methods is now the error thrown by the handler without coercing it into a string. If you need further type narrowing, you can use the `as` operator in your catch block. Bodyguard errors are regular `Error` instances with the message as one of the consts from `ERRORS`. | ||
The `error` returned from `soft*` methods is now the error thrown by the handler without coercing it into a string. If you need further type narrowing, you can use the `as` operator in your catch block. Bodyguard errors are regular `Error` instances with the message as one of the consts from `ERRORS`. | ||
|
||
### New Features | ||
|
||
- You can pass `convertPluses` as an option to the form methods to convert `+` to spaces in the form data when it's submitted in URL-encoded format. It won't affect multipart form data. | ||
You can pass `convertPluses` as an option to the form methods to convert `+` to spaces in the form data when it's submitted in URL-encoded format. It won't affect multipart form data. | ||
|
||
### Updates | ||
|
||
- Updated dependencies. | ||
Updated dependencies. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.