create-value-object

Create immutable value objects with value-based equality and Guard validation.

13|1|Updated Jun 28, 2023
One-click install
npx skills add https://github.com/jovicon/nestjs-clean-architecture-event-driven-template --skill create-value-object-jovicon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-value-object
Source: https://github.com/jovicon/nestjs-clean-architecture-event-driven-template/tree/main/.claude/skills/create-value-object
Command: npx skills add https://github.com/jovicon/nestjs-clean-architecture-event-driven-template --skill create-value-object-jovicon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Create a new value object in the domain layer following DDD patterns. Value objects model concepts without identity and enforce immutability and value-based equality.

Core Features & Use Cases

  • Immutable by design: no setters, only getters, ensuring safe sharing.
  • Value-based equality: two instances are equal if their values match.
  • Guided creation: private constructor with static create() factory and Guard-based validation.
  • Use Case: representing concepts like Email, Money, or Address within the domain.

Quick Start

Create a new value object named Money in the payments module.

Frequently Asked Questions about create-value-object

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

FAQPage Schema
How do I create an immutable value object in TypeScript?

To create an immutable value object in TypeScript, use a private constructor with a static create() factory method and enforce Guard-based validation. This ensures no setters are exposed, only getters, allowing safe sharing across modules.

What is a value object in domain-driven design?

A value object in domain-driven design models concepts without identity, relying instead on value-based equality. Two instances are equal if their values match, making them immutable and safe to share within the domain layer.

When should I use a value object instead of an entity?

Use a value object instead of an entity when modeling domain concepts without identity, such as Email, Money, or Address. Value objects enforce immutability and value-based equality, enabling safe composition and predictable behavior across modules.

Does this value object pattern require any external framework dependencies?

No, this value object pattern enforces no framework dependencies. It relies entirely on native TypeScript patterns like private constructors and static factory methods, keeping your domain layer isolated and predictable.

How do I validate data when creating a domain value object?

To validate data when creating a domain value object, use a static create() factory method with Guard-based validation. This guided creation process ensures invalid data never produces an instance, maintaining strict domain invariants.