Skip to content

Validate using AJV, parse using typebox #1051

Answered by sinclairzx81
RobinVdBroeck asked this question in Q&A
Discussion options

You must be logged in to vote

@RobinVdBroeck Hi,

Is it recommended that I do something like this?

Yes, this is fine. The Value.* functions can be used to provide additional functionality over Ajv. For parsing, it is recommended to implement a series of Value.* calls in a pipeline. The following is how TypeBox implements Parse internally.

https://github.com/sinclairzx81/typebox/blob/master/src/value/parse/parse.ts#L38-L68

// ------------------------------------------------------------------
// ParseReducer
// ------------------------------------------------------------------
type ReducerFunction = (schema: TSchema, references: TSchema[], value: unknown) => unknown

// prettier-ignore
const ParseReducer: ReducerFunction[

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RobinVdBroeck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants