Awesome-omni-skill joi

Use when building joi schemas, validating input data, defining custom types, conditional validation with .when(), cross-field references, custom error messages, or writing joi extensions. Standalone package that integrates with the @hapi ecosystem.

install
source · Clone the upstream repo
git clone https://github.com/diegosouzapw/awesome-omni-skill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/tools/joi" ~/.claude/skills/diegosouzapw-awesome-omni-skill-joi && rm -rf "$T"
manifest: skills/tools/joi/SKILL.md
source content

Joi

Quick Start

const Joi = require('@hapi/joi');

const schema = Joi.object({
    name: Joi.string().min(1).max(100).required(),
    age: Joi.number().integer().min(0),
    email: Joi.string().email()
});

const { error, value } = schema.validate(input);

Critical Rules

  1. Schemas are immutable - Every method returns a new schema instance; never mutate
  2. Validate at boundaries - Use
    validate()
    or
    attempt()
    at input boundaries; see validation
  3. Types extend base - All types inherit from
    any()
    ; see types overview
  4. Refs for cross-field - Use
    Joi.ref()
    for dynamic values across fields; see references
  5. Extend for custom types - Use
    Joi.extend()
    to create custom types; see extensions

Workflow

  1. Choose a type - types overview for all built-in types
  2. Add constraints - Chain rules like
    .min()
    ,
    .max()
    ,
    .pattern()
    ,
    .valid()
  3. Compose schemas - Nest
    Joi.object()
    ,
    Joi.array()
    ,
    Joi.alternatives()
  4. Add conditionals - Use
    .when()
    for dynamic schemas; see conditionals
  5. Customize errors - Override messages via
    .messages()
    or
    .error()
    ; see errors

Key Patterns

TopicReference
All built-in typestypes
Validation & optionsvalidation
References & templatesreferences
Conditional schemasconditionals
Error handlingerrors
Custom extensionsextensions
Metadata & introspectionmetadata
Common methods (any)any
Testing patternstesting