Skip to content

Commit ec220cb

Browse files
committed
feat(validateInput): add decodedInput
1 parent f2bbe73 commit ec220cb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/validateInput.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import {
33
validateWithTypeBox,
44
} from '@hello.nrfcloud.com/proto'
55
import type { MiddlewareObj } from '@middy/core'
6-
import type { Static, TSchema } from '@sinclair/typebox'
6+
import type { Static, StaticDecode, TSchema } from '@sinclair/typebox'
77
import type { ValueError } from '@sinclair/typebox/compiler'
8+
import { Value } from '@sinclair/typebox/value'
89
import type {
910
APIGatewayProxyEventV2,
1011
APIGatewayProxyStructuredResultV2,
@@ -64,11 +65,18 @@ export const validateInput = <Schema extends TSchema>(
6465
}
6566
console.debug(`[validateInput]`, `Input is valid`, schema.title)
6667
req.context.validInput = maybeValidInput.value
68+
req.context.decodedInput = Value.Decode(schema, maybeValidInput.value)
6769
return undefined
6870
},
6971
}
7072
}
7173

7274
export type ValidInput<Schema extends TSchema> = {
75+
/**
76+
* @deprecated Use `decodedInput` instead
77+
*
78+
* This will be removed in the next major version.
79+
*/
7380
validInput: Static<Schema>
81+
decodedInput: StaticDecode<Schema>
7482
}

0 commit comments

Comments
 (0)