简体   繁体   English

fastify.setValidatorCompiler 不是 function

[英]fastify.setValidatorCompiler is not a function

I have fastify 2.14 installed.我已经安装了 fastify 2.14 I am following the documentation to use custom validation library.我正在按照文档使用自定义验证库。

Here's my code:这是我的代码:

import fastify from 'fastify';

const app = fastify({});

app.setValidatorCompiler(({schema}) => data => schema.validate(data)); // setValidatorCompiler is not a function

console.log(app.setValidatorCompiler) // undefined 

export default app;

I also tried passing it in the route options and typescript doesn't recognize it as a field.我还尝试在路由选项中传递它,但 typescript 不将其识别为字段。

also setSerializerCompiler is not a function.setSerializerCompiler不是 function。

It seems like they have wrong documentation versioning.他们似乎有错误的文档版本控制。

I was reading version 2.14 documentation and it was for 3-alpha .我正在阅读2.14版文档,它是针对3-alpha

Installing the 3-alpha version solved my problem.安装3-alpha版本解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM