string

短い1行のテキスト入力用フィールドです。タイトル、スラッグ、著者名など、短い文字列に適しています。

基本例

{
  "name": "title",
  "type": "string",
  "label": "タイトル",
  "required": true
}

プロパティ

プロパティ必須説明
namestringYesフィールドの識別子
type"string"Yes"string"を指定
labelstringNoCMS上での表示名
notestringNo編集者向けの補足メモ
requiredbooleanNo必須フィールドかどうか
defaultstringNoデフォルト値
minLengthnumberNo最小文字数
maxLengthnumberNo最大文字数
patternstringNo正規表現パターン(バリデーション用)

使用例

タイトル

{
  "name": "title",
  "type": "string",
  "label": "タイトル",
  "required": true,
  "maxLength": 100
}

スラッグ(URL用)

{
  "name": "slug",
  "type": "string",
  "label": "スラッグ",
  "required": true,
  "pattern": "^[a-z0-9-]+$",
  "note": "半角英数字とハイフンのみ使用できます"
}

メールアドレス

{
  "name": "email",
  "type": "string",
  "label": "メールアドレス",
  "pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
}

デフォルト値付き

{
  "name": "status",
  "type": "string",
  "label": "ステータス",
  "default": "draft"
}

バリデーション

minLength / maxLength

文字数の制限を設定します。

{
  "name": "summary",
  "type": "string",
  "label": "要約",
  "minLength": 10,
  "maxLength": 200,
  "note": "10〜200文字で入力してください"
}

pattern

正規表現でフォーマットを制限します。

{
  "name": "phone",
  "type": "string",
  "label": "電話番号",
  "pattern": "^[0-9]{2,4}-[0-9]{2,4}-[0-9]{4}$",
  "note": "例: 03-1234-5678"
}

textとの違い

フィールド用途UI
string短いテキスト1行の入力欄
text長いテキスト複数行のテキストエリア

タイトルや名前など短い文字列にはstring、説明文や本文にはtextまたはrichtextを使用してください。