When prompting, inputs should be validated immediately
- Vorherrschende Sprache
- Go
- Sterne
- 16
- Forks
- 4
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
As a template user, when I'm interactively entering input values and I enter a value that fails validation, I want to find out immediately and try again, rather than continuing and failing later.
There's some trickiness here. A validation rule might reference multiple inputs, like `rule: 'bool(inputA) || bool(inputB)`. We can't evaluate this expression until we have values for both inputA and inputB. In the worse case, every rule might reference every variable.
One idea that might be possible: look at the CEL ASTs to see what identifiers they reference (this might be possible using [ReferenceInfo](https://pkg.go.dev/github.com/google/cel-go@v0.18.2/common/ast#ReferenceInfo)). Using that data, we could try one of these ideas:
- Change the order that we prompt for inputs so that we prefer to prompt for inputs whose validation rules only reference inputs that are already available.
- Divide the validation rules into two kinds: (1) those that only look at their own single input value, and (2) those that look at other input values. Execute the "kind 1" rules immeditely, but wait until all inputs have been collected before running the "kind 2" rules.
cc @gjonathanhong
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.