Agent 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 this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/joi
SKILL.md
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
- Schemas are immutable - Every method returns a new schema instance; never mutate
- Validate at boundaries - Use
validate()orattempt()at input boundaries; see validation - Types extend base - All types inherit from
any(); see types overview - Refs for cross-field - Use
Joi.ref()for dynamic values across fields; see references - Extend for custom types - Use
Joi.extend()to create custom types; see extensions
Workflow
- Choose a type - types overview for all built-in types
- Add constraints - Chain rules like
.min(),.max(),.pattern(),.valid() - Compose schemas - Nest
Joi.object(),Joi.array(),Joi.alternatives() - Add conditionals - Use
.when()for dynamic schemas; see conditionals - Customize errors - Override messages via
.messages()or.error(); see errors
Key Patterns
| Topic | Reference |
|---|---|
| All built-in types | types |
| Validation & options | validation |
| References & templates | references |
| Conditional schemas | conditionals |
| Error handling | errors |
| Custom extensions | extensions |
| Metadata & introspection | metadata |
| Common methods (any) | any |
| Testing patterns | testing |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?