We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
3.2.0
No response
18.0
Windows
win10
use fastify with TypeBoxTypeProvider,validate will auto cast sting to number,and auto cast sting to string[]
for example code blow:
//server.ts const server = fastify().withTypeProvider<TypeBoxTypeProvider>() fastify.post< { Body: User[] } >('/marks', { schema: { body: properties} }, async (request, reply) => { try { reply.code(200).send() } catch (err) { reply.code(400).send(err) } }), //validate.ts export const properties = Type.Object({ timestamp: Type.Readonly(Type.Integer()), users:Type.Optional(Type.Array(Type.String())) }) //testData1: { timestamp:1683687611279, users:["tom","jerry"] } expect:OK result:OK //testData2: { timestamp:"1683687611279", users:"tom" } expect:False result:OK
The text was updated successfully, but these errors were encountered:
This is expected because Fastify creates Ajv with coerceTypes: "array" by default: https://www.fastify.io/docs/latest/Reference/Validation-and-Serialization/#schema-validator.
coerceTypes: "array"
Sorry, something went wrong.
thanks,i will follow the doc
No branches or pull requests
Prerequisites
Fastify version
3.2.0
Plugin version
No response
Node.js version
18.0
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
win10
Description
use fastify with TypeBoxTypeProvider,validate will auto cast sting to number,and auto cast sting to string[]
for example code blow:
Steps to Reproduce
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: