Automated summary
This skill explains how to define and validate data with Yup schemas in JavaScript/TypeScript, including conditional validation and type inference.
Strengths
- Covers object, nested, and common validators (email, regex, oneOf, min/max)
- Demonstrates conditional validation with .when() and cross-field checks via yup.ref
- Explains type inference with InferType as a single source of truth
- Honestly notes that Zod may be a better fit for new projects
Limitations
- Does not detail error handling of the returned ValidationError beyond abortEarly
- No concrete integration examples with Formik or react-hook-form despite mentioning them
- Examples are TypeScript-only, without a plain JavaScript variant
Use it when adding form, API request, or configuration validation with Yup, especially in an existing Formik-based project.
Avoid it when starting from scratch or when advanced TypeScript inference matters, where Zod is the better choice.
Security analysis
SafeThis is pure documentation for the Yup validation library. It contains no executable instructions, no shell commands, no network calls, and no credential handling. Code samples are standard JavaScript/TypeScript validation snippets with no destructive or exfiltrating behavior.
No concerns found
How this analysis is madeExamples
Create a Yup schema for a signup form with name, email, and password, and give me the TypeScript type inferred from it.Write a Yup schema where email is required only if contactMethod is 'email', otherwise require a phone matching +digits.Add a Yup confirmPassword field that must match the password field, with a clear error message.name: yup description: >- 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. license: Apache-2.0 compatibility: 'Any JavaScript runtime' metadata: author: terminal-skills version: 1.0.0 category: development tags: [yup, validation, schema, forms, typescript]
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: falsereturns all errors at once — better UX than one-at-a-time.- Use
InferTypeto 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.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/yup-schema-validation-ms47vp9b' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/yup-schema-validation-ms47vp9b/download' --output '.skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md.part' && mv '.skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md.part' '.skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Environment declared by the author: Any JavaScript runtime
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md' && test -s '.skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/yup' && cp -R '.skill-downloads/yup-schema-validation-ms47vp9b' '.claude/skills/yup'Cursor
test -f '.skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md' && test -s '.skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/yup' && cp -R '.skill-downloads/yup-schema-validation-ms47vp9b' '.cursor/skills/yup'Codex
test -f '.skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md' && test -s '.skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/yup' && cp -R '.skill-downloads/yup-schema-validation-ms47vp9b' '.agents/skills/yup'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/yup-schema-validation-ms47vp9b'openskills read 'yup-schema-validation-ms47vp9b'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/yup-schema-validation-ms47vp9b/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.