mcpField
V
value-objects-and-dtos

value-objects-and-dtos

github.com/dev-toolingsDevelopment22791 installsUpdated 3w ago
Repository

About value-objects-and-dtos

A Symfony development skill for modeling domain values with value objects and boundary data with DTOs. It guides immutable designs, Doctrine persistence, and tests for invariants.

Key features

  1. 01Separate value objects from DTOs
  2. 02Validate immutable values at construction
  3. 03Use value-based equality and operations
  4. 04Persist value objects as Doctrine embeddables
  5. 05Keep input and output DTOs separate
  6. 06Test each invariant

Use cases

  1. 01Replace raw scalars for domain concepts
  2. 02Model request and API boundary data
  3. 03Store value objects in Doctrine entities

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dev-toolings/superpowers-symfony --skill value-objects-and-dtos

After installing, type/value-objects-and-dtosin Claude Code to confirm it loaded.

Bundled filesreference.md

Details

From the project README

Value Objects And Dtos (Symfony)

Use when

  • A domain concept with rules of its own (money, email, address) travels as raw scalars.
  • Data crosses a boundary: request input, API output, message payload.
  • Storing a value object inside a Doctrine entity.

Default workflow

  1. Decide: a value object for a domain concept with invariants, a DTO for data crossing a boundary.
  2. Make it readonly, validate in the constructor, and fail fast.
  3. Give value objects equality by value and operations that return new instances.
  4. Persist value objects as Doctrine embeddables.
  5. Keep input DTOs (validation constraints) apart from output DTOs (serializer attributes).

Guardrails

  • No setters and no mutation: a change returns a new instance.
  • DTOs carry data only, with no behavior.
  • Never expose entities directly as API input or output.
  • Store money as an integer in minor units, never as a float.

Progressive disclosure

  • Use this file for execution posture and risk controls.
  • Open references when deep implementation details are needed.

Output contract

  • Value objects with their invariants and equality.
  • Input and output DTOs, and their mapping to and from entities.
  • Unit tests for each invariant.

References

  • reference.md

Comments

Markdown supported