Enum values are not validated
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- typescript
- 領域
- tooling
調査の方向性
まず、frontmatter の値が options 配列に存在しない enum フィールドで問題を再現し、次に Contentlayer のビルドとスキーマ検証のエントリーポイントを追跡します。ビルドが無効な値を拒否し、有効な enum 値については引き続きドキュメントと TypeScript 型が生成されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
I've seen some examples on issues of people using a field of type enum to specify the page locale.
---
locale: 'en'
---
(...)
defineDocumentType(() => ({
[...],
fields: {
locale: {
type: 'enum',
options: ['en', 'es', 'de'],
required: true
}
}
}));
I've just seen on contentlayer@0.3.0 that if you have a file with an invalid enum value (not in the options array), then the build will complete successfully.
---
locale: 'not in the options array'
---
(...)
$ yarn contentlayer build
yarn run v1.22.19
$ /(...)/node_modules/.bin/contentlayer build
Generated 2 documents in .contentlayer
Done in 1.32s.
I understand that even if it does not validate values, the enum type field is really useful once it automatically generates TS types, but given that we can validate fields with required, shouldn't we also be able to validate the if the field value matches what we defined on the schema? (In the case of enum fields)
- 主要言語
- TypeScript
- スター
- 3.5k
- フォーク
- 192
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
contentlayerdev/contentlayer のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
contentlayerdev/contentlayer#506 · コメント 84 件 · リアクション 47 件 ·
-
Poor/broken monorepo DX: can't specify .contentlayer/ output path, no docs for custom config path オープンhelp wanted meta: never-stale needs-research
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
contentlayerdev/contentlayer#464 · コメント 4 件 · リアクション 9 件 ·
-
State of the project オープンmeta: never-stale
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
contentlayerdev/contentlayer#429 · コメント 49 件 · リアクション 83 件 ·
-
meta: never-stale topic: markdown/mdx
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
contentlayerdev/contentlayer#421 · リアクション 4 件 ·
-
meta: never-stale needs-research topic: schema
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
contentlayerdev/contentlayer#420 ·
contentlayerdev/contentlayer の issue をすべて見る
似ている issue
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
Mend: dependency security vulnerability untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100