• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Renewmm
V2EX  ›  程序员

[TypeScript]使用 data-annotations 为你减少 80%的校验过程

  •  
  •   Renewmm · Nov 16, 2020 · 1503 views
    This topic created in 2122 days ago, the information mentioned may be changed or developed.

    在开发过程中,我们常常需要针对一些数据做校验,例如一些必填项 /数据格式 /取值区间等

    我受够了那些 if(!s || !s.Trim().length) 在一些请求模型中同样的事情可能需要发生数次

    在寻找一些解决方案无果后,我尝试制作了 data-annotations 它能让你快速的去使用一些限制器来做到集中校验,在做到模型后,只需一个调用即可拿到所有的错误信息

    项目地址 github.com/wmm-xs/DataAnnotations

    有没有大佬来指出一下什么不足的。有 Star 就更好了

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   936 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 20:37 · PVG 04:37 · LAX 13:37 · JFK 16:37
    ♥ Do have faith in what you're doing.