Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: type of validation function #4283

Merged
merged 9 commits into from Sep 19, 2022
Merged

Conversation

budarin
Copy link
Contributor

@budarin budarin commented Sep 16, 2022

Checklist

types/request.d.ts Outdated Show resolved Hide resolved
@budarin budarin changed the title fix: types of validation functions in request fix: types of validation function Sep 16, 2022
@budarin budarin changed the title fix: types of validation function fix: type of validation function Sep 16, 2022
docs/Reference/Request.md Outdated Show resolved Hide resolved
docs/Reference/Request.md Outdated Show resolved Hide resolved
@Uzlopak Uzlopak requested a review from Eomm September 18, 2022 09:33
@Uzlopak
Copy link
Contributor

Uzlopak commented Sep 18, 2022

@Eomm ptal

@@ -133,6 +138,8 @@ The optional parameter `httpPart`, if provided, is forwarded directly
the `ValidationCompiler`, so it can be used to compile the validation
function if a custom `ValidationCompiler` is provided for the route.

This function has property errors. Errors encountered during the last validation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s add a small note just to indicate that this will only work this way of they’re using the default Fastify’s setup, if they’re tricking its own ValidationCompiler, most likely the behavior won’t be the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you arrange the text, please?

@@ -14,6 +15,11 @@ export interface RequestGenericInterface {
Headers?: RequestHeadersDefault;
}

export interface ValidationFunction {
(input: any): boolean
errors?: null | ErrorObject[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we have also an unknown type for allowing inference maybe?
Just to match it with my prior point that devs can implement its own compiler which bifurcates from the default behaviour?

Copy link
Contributor Author

@budarin budarin Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to me that a separate issue with tests is needed here to account for this factor

In any case, I will not be able to handle this case (

Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please include a tsd test?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Uzlopak Uzlopak merged commit b5e4157 into fastify:main Sep 19, 2022
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants