GithubHelp home page GithubHelp logo

精读 《Nestjs 文档》 about weekly HOT 7 CLOSED

ascoders avatar ascoders commented on April 28, 2024
精读 《Nestjs 文档》

from weekly.

Comments (7)

ascoders avatar ascoders commented on April 28, 2024

由于临近双十一,太忙了,此次暂时不讨论,待会直接上文章。

from weekly.

Pines-Cheng avatar Pines-Cheng commented on April 28, 2024

双十一还早吧。。。

from weekly.

llk2yq avatar llk2yq commented on April 28, 2024

你好,在知乎和掘金看到了这篇文章,文章里讲到了nestjs里参数验证的部分,其中“对于不同的请求做不同的校样”,请问有没有例子可供参考?
我目前是根据官方文档用了pipe , 但是这样会导致默认全部校验,望指点,感激不尽。

from weekly.

ascoders avatar ascoders commented on April 28, 2024

是对 “不同实体” 做不同校验,方式是给实体添加装饰器来完成:

@Column({
	comment: '配置 JSON',
	length: 5000,
})
@Validator.IsString({ message: '必须为字符串' })
@Validator.Length(0, 5000, { message: '长度在 0~5000' })
content: string;

from weekly.

llk2yq avatar llk2yq commented on April 28, 2024

@ascoders 谢谢,如果方便请移步这里:segmentfault,有详细的描述。

我想请教的是,一个实体,定义的时候会声明校验规则(如你上面所写),在请求的时候可以通过pipe来进行参数验证,可是这个验证默认是 全部验证 ,即所有字段需要符合实体类里定义的规则,可是如你那篇文章里所说一样,有些请求不需要验证所有字段(例如删除和修改),此时具体应该怎样实现?

我根据你所写的 EverythingSubscriber 并不能实现(技术比较渣),请问能否给个demo,或者伪代码,真心感谢~!

from weekly.

Zyj163 avatar Zyj163 commented on April 28, 2024

上传文件FileInterceptor里MulterOptions的storage要怎么创建啊,有没有像multer中的diskStorage,在哪里导入,有人知道吗

from weekly.

Suvern avatar Suvern commented on April 28, 2024

不是很能理解数据库跑在docker里的操作,不方便持久化处理,而且docker-compose会把项目和数据库混在一起。

from weekly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.