angular / angular/angular-cli

Schematics schema should take custom validation functions

未关闭
#12,705 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
area: @angular-devkit/schematics feature feature: insufficient votes
主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
14 小时 23 分钟
30 天内合并 PR
162

描述

### Bug Report or Feature Request (mark with an `x`)
```
- [ ] bug report -> please search issues before submitting
- [x] feature request
```

### Desired functionality
I would like to be able to specify validation functions for options of a schematic in the schema. JSON Schema does have some [built-in validation](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6), but this doesn't cover everything.

Here are a couple of examples that are not covered by JSON Schema:

- An option for the name of a new directory or file that should not match the name of an existing directory or file
- An option whose validity is based on a previous option's value

A workaround is to perform this type of validation within the schematic function itself, however, this is not the best possible user experience when using the prompt system. As a user, I would expect my input to be validated as I enter it, then re-prompted for if necessary. With this workaround, a user would need to re-invoke the program from the beginning if their input is found invalid within the schematic function.

贡献指南

打开贡献指南

调研方向

首先跟踪 schematic schemas 的验证方式,以及 prompt system 如何处理选项输入;issue 将 schematic function 列为当前的 workaround。完成的标准是:由 schema 定义的自定义验证能够覆盖跨选项和基于文件系统的情况,在 prompting 期间验证输入,并在输入无效时重新提示输入。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
cli, tooling
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。