value-object

Create TypeScript Value Objects with tryCreate validation and Result types.

Updated Mar 9, 2026
One-click install
npx skills add https://github.com/paulotks/CodeLeapTest --skill value-object-paulotks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: value-object
Source: https://github.com/paulotks/CodeLeapTest/tree/main/.agent/skills/value-object
Command: npx skills add https://github.com/paulotks/CodeLeapTest --skill value-object-paulotks

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps enforce data integrity and business rules within the application's domain by creating and managing Value Objects, ensuring data is valid and normalized before use.

Core Features & Use Cases

  • Value Object Creation: Generate new Value Objects following the project's strict pattern, including private constructors, tryCreate methods, and Result types for validation.
  • Validation & Normalization: Ensures that domain attributes meet specific criteria (e.g., not empty, within length limits) and are consistently formatted.
  • Use Case: When creating a new user, ensure the Username Value Object is used to validate that the username is not empty and does not exceed the maximum allowed length, returning a clear error if validation fails.

Quick Start

Create a new Value Object for a 'PostCategory' that must be a non-empty string.

Frequently Asked Questions about value-object

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce immutability and validation for domain attributes in TypeScript?

To enforce immutability and validation in TypeScript, use Value Objects with private constructors. This ensures domain attributes are strictly validated and normalized before use, preventing invalid data from entering the system.

How do I validate domain rules without throwing exceptions in TypeScript?

You can validate domain rules in TypeScript without throwing exceptions by using a tryCreate pattern. This method returns a Result type, providing a clear error if validation fails instead of interrupting execution flow.

What's the best way to create a Value Object in domain-driven design?

The best way to create a Value Object in domain-driven design is by following a strict pattern. This includes using private constructors, a tryCreate method, and a Result type to ensure data integrity and consistent formatting.

When do I need Value Objects in a TypeScript domain model?

You need Value Objects in a TypeScript domain model when creating attributes that require strict validation rules, such as ensuring a Username is not empty or a PostTitle stays within length limits.

Can I use this approach to normalize data formats for domain entities?

Yes, you can use Value Objects to normalize data formats for domain entities. They ensure that attributes meet specific criteria and are consistently formatted before the data is utilized.