[Feature Request] support subtyping of primitives
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 20/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- backend
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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?)?
- 主要言語
- TypeScript
- スター
- 2.9k
- フォーク
- 157
- 平均マージ
- 11時間 42分
- マージ済み PR(30日)
- 20
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
zenstackhq/zenstack のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
zenstackhq/zenstack#2873 ·
メンテナーはふだん 1 日以内に返信
-
runtime
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
zenstackhq/zenstack#2868 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
zenstackhq/zenstack#2694 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
zenstackhq/zenstack#2659 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
zenstackhq/zenstack#2542 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
zenstackhq/zenstack の issue をすべて見る
似ている issue
-
DB-plane provider_chat_options.* is accepted by config set but never merged into the loaded configオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Bump Firebase JS SDK (12.19.0 → 13.0.0)対応中かも @SelaseKay が今日担当しました。 オープンNeeds Attention type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
invertase/react-native-firebase#9364 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
cloudflare/mcp#271 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 4 日以内に返信
-
e2e-failure ready-to-code
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
redhat-developer/rhdh-plugin-export-overlays#4261 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信