Symfony Validation logo

Symfony Validation

Community
aligundogdu
symfony-validation

Symfony 3-layer validation in hexagonal architecture: Presentation request DTOs with #[MapRequestPayload], Application command validation via Messenger validation middleware, Domain invariants in value objects; custom constraints with named arguments, #[ExtendsValidationFor] (7.4+), validation groups. Use when: validation, validator, constraint, DTO validation, input validation, invariant, assert, validation group, custom constraint

Overview

Publisheraligundogdu
Repositorysymfony-hexagonal-skill
Skill namesymfony-validation
Stars
35
Forks
4
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by aligundogdu on GitHub. Read the source before you install it.

Installation

Install the Symfony Validation AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/aligundogdu/symfony-hexagonal-skill/tree/main/skills/symfony-validation
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/aligundogdu/symfony-hexagonal-skill.git /tmp/symfony-hexagonal-skill
mkdir -p .claude/skills
cp -r /tmp/symfony-hexagonal-skill/skills/symfony-validation .claude/skills/symfony-validation
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Symfony Validation in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Symfony Validation on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Symfony Validation is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Symfony Validation

You are an expert in multi-layer validation within Symfony hexagonal architecture.

When to Activate

  • User needs input validation
  • User asks about validation strategies
  • User needs custom constraints
  • User mentions DTO validation or domain invariants

Version Notes

FeatureRequiresFallback
#[MapRequestPayload] / #[MapQueryString] auto-validationSymfony 6.3manual ValidatorInterface::validate()
Named-argument constraints Length(min: 2)all versions; arrays removed in 8.0-
Custom constraint with named-argument constructorrequired for 8.0 (arrays deprecated 7.3)same code works on 6.4
#[ExtendsValidationFor(Target::class)]Symfony 7.4validate a Request DTO / Command instead
When(..., otherwise: [...])Symfony 7.3two constraints with groups

3-Layer Validation Strategy

Layer 1: Presentation (Input Validation)

Where: Request DTOs in Presentation/{Module}/API/Request/ What: Format validation: is the input well-formed? How: Constraints on the DTO + #[MapRequestPayload] (422 on failure)

php
namespace App\Presentation\User\API\Request;

use Symfony\Component\Validator\Constraints as Assert;

final readonly class RegisterUserRequest
{
    public function __construct(
        #[Assert\NotBlank]
        #[Assert\Email]
        public string $email = '',

        #[Assert\NotBlank]
        #[Assert\Length(min: 2, max: 100)]
        public string $name = '',

        #[Assert\NotBlank]
        #[Assert\Length(min: 8)]
        #[Assert\Regex(pattern: '/[A-Z]/', message: 'Must contain uppercase')]
        #[Assert\Regex(pattern: '/[0-9]/', message: 'Must contain a number')]
        public string $password = '',
    ) {
    }
}

// Controller
public function register(#[MapRequestPayload] RegisterUserRequest $request): JsonResponse

Layer 2: Application (Command Validation)

Where: Command/Query classes, validated by the Messenger validation middleware What: Use-case pre-checks: are the values acceptable for this use case (including checks that need ports, e.g. uniqueness)? How: Symfony Validator constraints on command properties

php
final readonly class RegisterUser
{
    public function __construct(
        #[Assert\NotBlank]
        #[Assert\Email]
        #[UniqueEmail]
        public string $email,

        #[Assert\NotBlank]
        public string $name,

        #[Assert\NotBlank]
        public string $plainPassword,
    ) {
    }
}

The validation middleware validates before handler execution and throws Messenger\Exception\ValidationFailedException (mapped to 422 by ApiExceptionSubscriber). Commands dispatched from CLI, Scheduler or other handlers are validated too, which is why this layer exists even with Layer 1.

Layer 3: Domain (Invariants)

Where: Entity constructors/factories, value objects, business methods What: Business invariants: is the operation valid in domain context? How: Pure PHP checks, throw domain exceptions (no #[Assert] attributes in Domain)

php
// Value object self-validates
final readonly class Email
{
    public function __construct(public string $value)
    {
        if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) {
            throw InvalidEmailException::forValue($value);
        }
    }
}

// Entity protects invariants
final class Order
{
    public function cancel(string $reason, \DateTimeImmutable $now): void
    {
        if (!$this->status->canTransitionTo(OrderStatus::CANCELLED)) {
            throw InvalidOrderTransitionException::from($this->id->value, $this->status, OrderStatus::CANCELLED);
        }
        // ...
    }
}

References

See references/ for detailed guides:

  • validation-layers.md - Full examples for each layer, custom constraints, #[ExtendsValidationFor], groups, pre-6.3 fallback

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Symfony Validation AI skill do?

Symfony 3-layer validation in hexagonal architecture: Presentation request DTOs with #[MapRequestPayload], Application command validation via Messenger validation middleware, Domain invariants in value objects; custom constraints with named arguments, #[ExtendsValidationFor] (7.4+), validation groups. Use when: validation, validator, constraint, DTO validation, input validation, invariant, assert, validation group, custom constraint

Why use Symfony Validation on TypingMind?

Because you install it once and use it with any model. Symfony Validation is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Symfony Validation in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/aligundogdu/symfony-hexagonal-skill/tree/main/skills/symfony-validation. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Symfony Validation?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Symfony Validation?

As many as you like. As long as a model supports skills, you can use Symfony Validation with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Symfony Validation AI skill free?

It is published on GitHub by aligundogdu. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇