jpskill.com
🛠️ 開発・MCP コミュニティ

yup

Yupスキーマを使って、フォームの入力内容やAPIのリクエストなど、JavaScript/TypeScriptで扱うデータの形式が正しいかチェックし、安全で信頼性の高いシステムを構築するSkill。

📜 元の英語説明(参考)

Validate data with Yup schemas. Use when adding form validation, defining API request schemas, validating configuration, or building type-safe validation pipelines in JavaScript/TypeScript.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Yupスキーマを使って、フォームの入力内容やAPIのリクエストなど、JavaScript/TypeScriptで扱うデータの形式が正しいかチェックし、安全で信頼性の高いシステムを構築するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o yup.zip https://jpskill.com/download/15586.zip && unzip -o yup.zip && rm yup.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15586.zip -OutFile "$d\yup.zip"; Expand-Archive "$d\yup.zip" -DestinationPath $d -Force; ri "$d\yup.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して yup.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → yup フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Yup

概要

Yup は JavaScript のためのスキーマ検証ライブラリです。スキーマを宣言的に定義し、データを検証し、詳細なエラーメッセージを取得できます。Formik、react-hook-form、およびスタンドアロンで動作します。TypeScript ファーストで、型推論に対応しています。

手順

ステップ 1: スキーマ

import * as yup from 'yup'

const userSchema = yup.object({
  name: yup.string().min(2).max(100).required(),
  email: yup.string().email().required(),
  age: yup.number().positive().integer().min(13).max(120),
  role: yup.string().oneOf(['admin', 'member', 'viewer']).default('member'),
  tags: yup.array().of(yup.string()).min(1).max(10),
  address: yup.object({
    street: yup.string().required(),
    city: yup.string().required(),
    zip: yup.string().matches(/^\d{5}$/, 'Must be 5 digits'),
  }),
})

// 検証
const user = await userSchema.validate(data, { abortEarly: false })

// 型推論
type User = yup.InferType<typeof userSchema>

ステップ 2: カスタム検証

const passwordSchema = yup.string()
  .min(8)
  .matches(/[A-Z]/, 'Must contain uppercase')
  .matches(/[0-9]/, 'Must contain number')
  .matches(/[^A-Za-z0-9]/, 'Must contain special character')

const signupSchema = yup.object({
  password: passwordSchema.required(),
  confirmPassword: yup.string()
    .oneOf([yup.ref('password')], 'Passwords must match')
    .required(),
})

ステップ 3: 条件付き検証

const schema = yup.object({
  contactMethod: yup.string().oneOf(['email', 'phone']).required(),
  email: yup.string().when('contactMethod', {
    is: 'email',
    then: (s) => s.email().required('Email required when contact method is email'),
  }),
  phone: yup.string().when('contactMethod', {
    is: 'phone',
    then: (s) => s.matches(/^\+\d{10,15}$/).required('Phone required'),
  }),
})

ガイドライン

  • abortEarly: false は、一度にすべてのエラーを返します。一度に 1 つずつよりも優れた UX です。
  • InferType を使用して、スキーマから TypeScript の型を導出します。単一の信頼できる情報源です。
  • 新しいプロジェクトでは、代わりに Zod を検討してください。より優れた TypeScript 推論とエコシステムを提供します。
  • Yup は、依然として Formik 統合の標準です。
  • 条件付き検証には .when() を使用します。特定のコンテキストでのみ必要なフィールドに使用します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Yup

Overview

Yup is a schema validation library for JavaScript. Define schemas declaratively, validate data, and get detailed error messages. Works with Formik, react-hook-form, and standalone. TypeScript-first with type inference.

Instructions

Step 1: Schemas

import * as yup from 'yup'

const userSchema = yup.object({
  name: yup.string().min(2).max(100).required(),
  email: yup.string().email().required(),
  age: yup.number().positive().integer().min(13).max(120),
  role: yup.string().oneOf(['admin', 'member', 'viewer']).default('member'),
  tags: yup.array().of(yup.string()).min(1).max(10),
  address: yup.object({
    street: yup.string().required(),
    city: yup.string().required(),
    zip: yup.string().matches(/^\d{5}$/, 'Must be 5 digits'),
  }),
})

// Validate
const user = await userSchema.validate(data, { abortEarly: false })

// Type inference
type User = yup.InferType<typeof userSchema>

Step 2: Custom Validation

const passwordSchema = yup.string()
  .min(8)
  .matches(/[A-Z]/, 'Must contain uppercase')
  .matches(/[0-9]/, 'Must contain number')
  .matches(/[^A-Za-z0-9]/, 'Must contain special character')

const signupSchema = yup.object({
  password: passwordSchema.required(),
  confirmPassword: yup.string()
    .oneOf([yup.ref('password')], 'Passwords must match')
    .required(),
})

Step 3: Conditional Validation

const schema = yup.object({
  contactMethod: yup.string().oneOf(['email', 'phone']).required(),
  email: yup.string().when('contactMethod', {
    is: 'email',
    then: (s) => s.email().required('Email required when contact method is email'),
  }),
  phone: yup.string().when('contactMethod', {
    is: 'phone',
    then: (s) => s.matches(/^\+\d{10,15}$/).required('Phone required'),
  }),
})

Guidelines

  • abortEarly: false returns all errors at once — better UX than one-at-a-time.
  • Use InferType to derive TypeScript types from schemas — single source of truth.
  • For new projects, consider Zod instead — better TypeScript inference and ecosystem.
  • Yup is still the standard for Formik integration.
  • .when() for conditional validation — fields required only in certain contexts.