Schematics schema should take custom validation functions

Aberta
#12,705 3 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
typescript
Domínio
cli, tooling

Direção de pesquisa

Comece rastreando como os schematic schemas são validados e como o prompt system lida com a entrada de opções; a issue nomeia a schematic function como o workaround atual. O trabalho estará concluído quando a validação personalizada definida pelo schema puder abranger casos entre opções e casos baseados no sistema de arquivos, validar a entrada durante o prompting e solicitar a entrada novamente quando ela for inválida.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

area: @angular-devkit/schematics feature feature: insufficient votes
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, 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.

Linguagem predominante
TypeScript
Estrelas
27k
Forks
11.8k
Merge médio
16h 35min
PRs com merge (30d)
176

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de angular/angular-cli

Todas as issues de angular/angular-cli

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.