Add valibot schemas for trail type #14542
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this change?
This PR is introducing
valibot
for theFETrailType
. The advantage of using valibot is that we can validate theFETrailType
json responses in the client. Currently the client side calls to get the list of trails are not doing any validation.The cncern of doing this, is that we have to replace all the types within FETrailType into their alternative valibot schemas. Then we can use them as typescript types by using the valibot
Output
type. e.g.type FETrailType = Output<typeof FETrailTypeSchema>;
.This means, the
FEFormat
also needs to be converted into a valibot schema. But because FEFormat is used in all of the article and front data models that are processed server side, we had to run gen-schemas to generate new json schemas. The generated schemas seems to have lost their named types for the new valibot types, which is not idea.The TypeScript JSON Schema generator (typescript-json-schema) is now inlining the entire type definition instead of creating a reference to a named type.
We are going to look into how to fix this.