Giter Site home page Giter Site logo

Comments (3)

FateRiddle avatar FateRiddle commented on May 17, 2024

感觉上, object pattern properties在校验JSON数据上很有用,写一个pattern就能校验一大批字段。但是在表单场景,每个表单元素的schema都应该是明确的schema。因为schema不仅描述了数据校验,也同时描述了表单的UI,感觉非常难以想象一个确实必须使用pattern的表单渲染场景,能否给个现实场景? @Prodesire

from x-render.

Prodesire avatar Prodesire commented on May 17, 2024

感觉上, object pattern properties在校验JSON数据上很有用,写一个pattern就能校验一大批字段。但是在表单场景,每个表单元素的schema都应该是明确的schema。因为schema不仅描述了数据校验,也同时描述了表单的UI,感觉非常难以想象一个确实必须使用pattern的表单渲染场景,能否给个现实场景? @Prodesire

其实 patternProperties 非常常见。在我们内部使用场景中,用户要新建一个资源,他告诉服务端必要的信息(比如产品、类型),然后点一个按钮来动态生成资源。服务端会返回根据给定的信息找到相关的数据,动态生成出表示这个资源的数据结构(比如说这个资源有哪些属性,每个属性是什么类型,涉及到哪些增删改查API)。这份元数据就是要填写到表单中,由于元数据是动态生成的,深层次的数据结构中并不知道一个字典它有哪些key(就比如说我并不能事先知道资源的属性名称是什么,这些都是动态生成的,所以表单的校验规则中需要有 patternProperties进行正则匹配)。
@FateRiddle

from x-render.

FateRiddle avatar FateRiddle commented on May 17, 2024

schema本身也可以动态生成吧?Object Pattern Properties 太贴数据校验规范,而且写起来对于不熟悉JSON schema的用户来说也不友好。至于批量校验,会用别的方式来做。

from x-render.

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.