damusix/skills

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 hapijs ecosystem.

First seen Feb 15, 2026

Installation

$ npx skills add damusix/skills --skill joi

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from damusix/skills · top by installs.

npx skills add damusix/skills

Browse all from damusix/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 63
Default branch main
Open issues 0
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,347 B
  • docs SUMMARY.md 260 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 34 installs

SKILL.md

Joi

Quick Start

const Joi = require('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](reference/validation.md)
  3. Types extend base - All types inherit from any(); see [types overview](reference/types.md)
  4. Refs for cross-field - Use Joi.ref() for dynamic values across fields; see [references](reference/references.md)
  5. Extend for custom types - Use Joi.extend() to create custom types; see [extensions](reference/extensions.md)

Workflow

  1. Choose a type - [types overview](reference/types.md) 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](reference/conditionals.md)
  5. Customize errors - Override messages via .messages() or .error(); see [errors](reference/errors.md)

Common Patterns

Conditional validation with .when()

const schema = Joi.object({ type: Joi.string().valid('email', 'sms').required(), address: Joi.when('type', { is: 'email', then: Joi.string().email().required(), otherwise: Joi.string().pattern(/^\+?[1-9]\d{1,14}$/).required() }) });

Cross-field references with Joi.ref()

const schema = Joi.object({ password: Joi.string().min(8).required(), confirmPassword: Joi.string().valid(Joi.ref('password')).required() .messages({ 'any.only': 'passwords must match' }), startDate: Joi.date().required(), endDate: Joi.date().greater(Joi.ref('startDate')).required() });

Key Patterns

Topic Reference
All built-in types [types](reference/types.md)
Validation & options [validation](reference/validation.md)
References & templates [references](reference/references.md)
Conditional schemas [conditionals](reference/conditionals.md)
Error handling [errors](reference/errors.md)
Custom extensions [extensions](reference/extensions.md)
Metadata & introspection [metadata](reference/metadata.md)
Common methods (any) [any](reference/any.md)
Testing patterns [testing](reference/testing.md)