assertions

Create a custom PHP Assert utility extending Webmozart\Assert for domain validation.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/dairectiv/dairectiv --skill assertions
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: assertions
Source: https://github.com/dairectiv/dairectiv/tree/main/.claude/skills/assertions
Command: npx skills add https://github.com/dairectiv/dairectiv --skill assertions

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a centralized, project-specific assertion utility for PHP to ensure data validity and type safety across the domain layer, reducing bugs and boilerplate in value objects, aggregates, and domain services.

Core Features & Use Cases

  • Custom Assert class that extends Webmozart\Assert with project-specific behavior and error handling.
  • Enforces domain invariants within value object factories, aggregates, and guard clauses.
  • Guides consistent usage, messaging, and testing to maintain invariant enforcement across the codebase.

Quick Start

Install project dependencies via Composer and begin using the custom Assert in your domain classes to validate inputs, enforce constraints, and throw the project's InvalidArgumentException on failure.

Frequently Asked Questions about assertions

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

FAQPage Schema
How do I validate domain invariants in PHP value objects?▼

You validate domain invariants in PHP value objects by using a custom Assert utility that extends Webmozart\Assert. This approach enforces data validity directly within factories and guard clauses, throwing project-specific exceptions when constraints fail.

How do I enforce type safety and non-empty inputs in PHP aggregates?▼

To enforce type safety and non-empty inputs in PHP aggregates, apply a centralized assertion class within your domain services. It validates inputs and throws an InvalidArgumentException to prevent invalid state from propagating through your codebase.

What is the best way to centralize PHP validation logic for domain models?▼

The best way to centralize PHP validation logic for domain models is creating a custom Assert class that extends Webmozart\Assert. This reduces boilerplate across value objects and aggregates while ensuring consistent error messaging and invariant enforcement.

Can I use Webmozart\Assert to throw project-specific exceptions in PHP?▼

Yes, you can use Webmozart\Assert to throw project-specific exceptions by extending it with a custom assertion class. This allows your domain layer to maintain consistent error handling and messaging tailored to your project's requirements.

When do I need guard clauses for PHP domain validation?▼

You need guard clauses for PHP domain validation when protecting invariants in value object factories and aggregates. They ensure inputs meet constraints immediately, preventing invalid data from compromising domain model integrity.

Does PHP validation with custom assertions require testing?▼

PHP validation with custom assertions requires testing to maintain invariant enforcement across the codebase. The Skill includes usage guidelines and tests to guide consistent application and messaging of the custom assertion utility.