[Feature Request] support subtyping of primitives
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- backend
Direzione di ricerca
Design-level request: decide how primitive subtypes are declared and how validation attributes reach array elements, then carry that through ZModel parsing, validation and generated TypeScript types. Begin with how type declarations and @length-style attributes are parsed today and how scalar arrays are typed, and resolve the open question about nullable elements (PostTag?[]). Done means type PostTag { value String @length(1, 5) } used as PostTag[] validates each element, with tests covering arrays and nullability.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Currently, it is not possible to validate elements of scalar arrays:
model Post {
tags String[] @length(1, 5) // what if I wanted a tag itself to be between 1 and 5 characters?
}
Describe the solution you'd like
A clear and concise description of what you want to happen.
Allow subtyping of primitives so that validation attributes can be applied to them, then referenced as the element type of an array.
type PostTag {
value String @length(1, 5)
}
model Post {
value PostTag[]
}
The above method wouldn't require changes to the schema language grammar. However, I will still note that the following syntax could be more intuitive to some because it doesn't use the implicit value property like the above, and is more like a type alias.
type PostTag = String @length(1, 5)
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Validate in application code. But then there is some validation occurring as part of the schema definition and some happening elsewhere. It would be nice to centralize it.
Additional context
Add any other context or screenshots about the feature request here.
Open questions:
-
Nullable array elements
These (
String?[]) are not currently allowed. Would these subtypes be forced as non-nullable, and required to be marked as nullable at the usage site (PostTag?)?
- Lingua principale
- TypeScript
- Stelle
- 2.9k
- Fork
- 157
- Merge medio
- 11h 42m
- PR unite (30g)
- 20
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di zenstackhq/zenstack
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
zenstackhq/zenstack#2873 ·
I maintainer di solito rispondono entro 1 giorno
-
runtime
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
zenstackhq/zenstack#2868 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
zenstackhq/zenstack#2694 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
zenstackhq/zenstack#2659 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
zenstackhq/zenstack#2542 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di zenstackhq/zenstack
Issue simili
-
First unknown-user login after boot is one scrypt run slower than a real user's wrong passwordApertaarea: backend bug priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
snapotter-hq/SnapOtter#2254 ·
I maintainer di solito rispondono entro 1 giorno
-
bug ticket
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
cratestack/cratestack#1154 ·
I maintainer di solito rispondono entro 1 giorno
-
server 消息处理器 cmd 分支补显式错误回报——竞态非法命令现走未处理拒绝Forse già presa @openaddr l’ha presa oggi. Apertaready-for-agent refactor wayfinder:task
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openaddr/dafung-web#428 ·
I maintainer di solito rispondono entro 1 giorno
-
Flaky: mongodb-memory-server 'Port already in use' when another process starts a mongod concurrentlyApertaarea:testing bug effort:S priority:P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
lens:agent lens:process process
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
thebristolsound/birdbrain#1772 ·
I maintainer di solito rispondono entro 1 giorno