implement-value-objects

Implement immutable domain value objects with validation and equality checks.

Updated Oct 27, 2025
One-click install
npx skills add https://github.com/mariotoffia/gobridge --skill implement-value-objects
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: implement-value-objects
Source: https://github.com/mariotoffia/gobridge/tree/main/.cursor/skills/implement-value-objects
Command: npx skills add https://github.com/mariotoffia/gobridge --skill implement-value-objects

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides developers to implement immutable, self-validating value objects in a Domain-Driven Design context, ensuring invariants are preserved and domain concepts are expressed clearly.

Core Features & Use Cases

  • Immutable by design: value objects have no identity and are defined by their attributes.
  • Self-validation: constructors enforce valid states, preventing invalid data from entering the domain.
  • Equality by value: equality checks are based on all relevant attributes, not identity.
  • Composition & behavior: value objects can be composed into more complex types with domain behavior.
  • Testing guidance: provides table-driven tests and boundary-case coverage to validate behavior.

Quick Start

Create a new value object in your domain, implement a constructor with validation, add equality checks and small domain methods, then write unit tests and run them.

Frequently Asked Questions about implement-value-objects

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

FAQPage Schema
How do I implement immutable value objects with built-in validation in domain-driven design?

Implement immutable value objects by designing constructors that validate input and enforce invariants, ensuring attributes are set once and domain rules are preserved.

What is a value object and when do I need it in DDD?

A value object in DDD is an immutable type defined by its attributes with no identity. You need it to express domain concepts clearly and ensure invalid states are unrepresentable.

How do I test value object equality by attribute and validate boundary cases?

Test value object equality by attribute using table-driven unit tests that compare instances with identical values. Validate boundary cases to ensure constructor invariants hold.

Do I need external libraries or frameworks to create self-validating domain value objects?

No external libraries or frameworks are needed to create self-validating domain value objects. This approach relies on standard language features and unit tests to enforce invariants.

Can I compose complex domain types from basic value objects like money and temperature?

Yes, you can compose complex domain types from basic value objects like money and temperature. Value objects can be combined to build richer domain behavior across representations.

When should I avoid using immutable value objects in my domain model?

Avoid using immutable value objects for entities that require a distinct identity and lifecycle tracking. Value objects are suited for attributes defined by their values, not by identity.