知识卡片
输入规则随响应更新
服务输入规则变化时,只按旧人工文档硬编码的客户端可能继续提交无效数据。
丰富输入描述RID把必填、只读、正则、范围、长度、类型和可选项等约束放到运行时消息中,客户端按收到的规则验证输入,减少硬编码验证随服务演进而过时。
书中HAL-FORMS示例的options.inline区分展示文字与实际值,selectedValues给出已选值;M2M客户端可以忽略控件外观,仍须校验可选值。服务不提供RID时,可把人工文档转换为本地规则配置,并承担更新工作。
关联:[[本地补充链接与表单]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 超媒体客户端 · 查看原书依据
The Core section lists the following elements that clients should support: readOnly, regex, required, and templated. The Additional section lists elements that clients may support: cols, max, maxLength, min, minLength, placeholder, rows, step, and type. The Options support is a special class of input validation that implements describing enumerators (e.g., small, medium, large, etc.).
参考来源
- 位置:《RESTful Web API Patterns and Practices Cookbook》第4章《Hypermedia Clients》(来源项目book-sources:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch04.xhtml,配方4.11)
- 结论依据:原文以HAL-FORMS的核心、额外约束及Options示例说明运行时输入验证和显示文字与值的区分。
- 原始内容:The Core section lists the following elements that clients should support: readOnly, regex, required, and templated. The Additional section lists elements that clients may support: cols, max, maxLength, min, minLength, placeholder, rows, step, and type. The Options support is a special class of input validation that implements describing enumerators (e.g., small, medium, large, etc.).