Back to list
Dev-Int

create-value-object

by Dev-Int

Tests for help and skill :wink:

0🍴 0📅 Jan 16, 2026

SKILL.md


name: create-value-object description: 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.

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

InputExampleOutput
namePriceFieldShared/Entities/VO/ValueObjectName.php (if shared)
typestring, intBC/Entities/VO/ValueObjectName.php (if BC-specific)
validation['min' => 0]-
locationShared, Admin-

Process

StepAction
CreateUse template: value-object.php.tpl
Validatemake cs-fixer && make stan

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:

  • final readonly class, private constructor
  • Static factory: fromString(), fromInt(), fromCents(), etc.
  • Immutable (no setters)

Validation:

  • In factory method
  • Throw domain exceptions (not generic)
  • Clear error messages

Methods:

  • Getter: toString(), toInt(), toFloat()
  • Comparison: equals(), isGreaterThan(), etc.
  • Business logic if needed (e.g., add(), multiply())

Location Decision:

  • Shared/Entities/VO/ if used across multiple BCs (ResourceUuid, EmailField, NameField, PriceField)
  • BC/Entities/VO/ if BC-specific only (ArticleReference, SupplierCode, TaxRate)

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/

  • create-entity - Use VOs in entities
  • create-use-case - Pass VOs in requests

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon