Claude-skill-registry create-value-object
Create Value Object for domain modeling following DDD patterns. Use when you need to encapsulate primitive values with validation, business rules, and immutability. Creates reusable VOs like PriceField, EmailField, QuantityField with validation and domain logic.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/create-value-object" ~/.claude/skills/majiayu000-claude-skill-registry-create-value-object && rm -rf "$T"
manifest:
skills/data/create-value-object/SKILL.mdsource content
Create Value Object
Generate immutable Value Object with validation and business rules.
When to Use
- Encapsulate primitive values (string, int, float)
- Add validation to domain values
- Avoid primitive obsession
- Create reusable domain concepts
Inputs/Outputs
| Input | Example | Output |
|---|---|---|
| name | PriceField | (if shared) |
| type | string, int | (if BC-specific) |
| validation | ['min' => 0] | - |
| location | Shared, Admin | - |
Process
| Step | Action |
|---|---|
| Create | Use template: |
| Validate | |
Structure
Value Object (
final readonly, private constructor, static factory):
final readonly class ValueObjectName { private function __construct(private TypeHere $value) {} public static function fromString(string $value): self { if (empty($value)) { throw InvalidValueObject::empty(); } return new self($value); } public function toString(): string { return $this->value; } public function equals(self $other): bool { return $this->value === $other->value; } }
See:
docs/GLOSSARY.md#value-object for detailed definition
Rules
Class Structure:
class, private constructorfinal readonly- Static factory:
,fromString()
,fromInt()
, etc.fromCents() - Immutable (no setters)
Validation:
- In factory method
- Throw domain exceptions (not generic)
- Clear error messages
Methods:
- Getter:
,toString()
,toInt()toFloat() - Comparison:
,equals()
, etc.isGreaterThan() - Business logic if needed (e.g.,
,add()
)multiply()
Location Decision:
if used across multiple BCs (ResourceUuid, EmailField, NameField, PriceField)Shared/Entities/VO/
if BC-specific only (ArticleReference, SupplierCode, TaxRate)BC/Entities/VO/
Templates
value-object.php.tpl
Location:
.claude/templates/
References
- Value Object definition:
docs/GLOSSARY.md#value-object - Value Object pattern:
docs/QUICK_REF.md#value-object-pattern - Architecture:
docs/architecture.md#value-objects - Shared VOs:
src/Shared/Entities/VO/
Related Skills
- Use VOs in entitiescreate-entity
- Pass VOs in requestscreate-use-case