Skip to content

Commit

Permalink
#42 added _typeEnforcer as quick fix https://discord.com/channels/508…
Browse files Browse the repository at this point in the history
  • Loading branch information
bennobuilder committed Jul 7, 2024
1 parent c370b85 commit c467d76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/openapi-router/src/__tests__/playground.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@ describe('playground', () => {
it('types should work', async () => {
const openapiRouter = createExpressOpenApiRouter<paths>(Router());

const pathValibotAdapter = valibotAdapter(v.object({}));
const pathValibotAdapter = valibotAdapter(
v.object({
petId: v.number()
})
);

openapiRouter.get(
'/pet/{petId}',
{
// pathAdapter: createValidationAdapter([
// {
// key: 'pet',
// validate: (cx) => {
// // TODO
// }
// }
// ])
pathAdapter: pathValibotAdapter
},
async (req, res, next) => {
Expand Down
1 change: 1 addition & 0 deletions packages/validation-adapter/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface TValidationAdapter<
GValidateContext extends TBaseValidateContext<GValue> = TBaseValidateContext<GValue>
> {
_validationChain: TValidationChain<GValue, GValidateContext>;
_typeEnforcer?: GValue; // TODO: This field ensures that TypeScript enforces the generic type GValue consistently across different instances of TValidationAdapter
validate: <GInnerValidateContext extends GValidateContext = GValidateContext>(
cx: GInnerValidateContext
) => Promise<GInnerValidateContext>;
Expand Down

0 comments on commit c467d76

Please sign in to comment.