0
0
# Install this skill:
npx skills add joabgonzalez/ai-agents-framework --skill "yup"

Install specific skill from multi-skill repository

# Description

Schema validation for JavaScript objects with expressive API.

# SKILL.md


name: yup
description: Schema validation for JavaScript objects with expressive API.
skills:
- conventions
- typescript
dependencies:
yup: ">=1.0.0 <2.0.0"
allowed-tools:
- documentation-reader
- web-search


Yup Skill

Overview

Schema-based validation library for JavaScript and TypeScript with intuitive API.

Objective

Enable developers to define and validate data schemas with proper TypeScript integration and error handling.

Conventions

Refer to conventions for:

  • Error handling

Refer to typescript for:

  • Type inference from schemas

Yup Specific

  • Define schemas with proper types
  • Use TypeScript's InferType for type extraction
  • Implement custom validation methods
  • Handle validation errors appropriately
  • Use schema composition

Example

import * as yup from "yup";

const userSchema = yup.object({
  name: yup.string().required("Name is required"),
  email: yup.string().email("Invalid email").required("Email is required"),
  age: yup.number().positive().integer().min(18, "Must be 18 or older"),
});

type User = yup.InferType<typeof userSchema>;

try {
  const validUser: User = await userSchema.validate({
    name: "John",
    email: "[email protected]",
    age: 25,
  });
} catch (error) {
  if (error instanceof yup.ValidationError) {
    console.error(error.message);
  }
}

References

  • https://github.com/jquense/yup

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.