mcpField
F
form-types-validation

form-types-validation

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

About form-types-validation

A Symfony development skill for building form types and validation rules across entities, DTOs, and fields. It covers validation groups, transformers, form events, and tests for valid and invalid submissions.

Key features

  1. 01Build form types with explicit fields and options
  2. 02Place constraints on entities, DTOs, or fields
  3. 03Separate rules with validation groups
  4. 04Use transformers and form events when needed
  5. 05Test valid, invalid, and custom-constraint submissions

Use cases

  1. 01Create or modify a Symfony form type
  2. 02Apply different rules to registration and profile forms
  3. 03Convert form data that differs from the model
  4. 04Build custom constraints or multi-step forms

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dev-toolings/superpowers-symfony --skill form-types-validation

After installing, type/form-types-validationin Claude Code to confirm it loaded.

Bundled filesreference.md

Details

From the project README

Form Types Validation (Symfony)

Use when

  • Building or changing a Symfony form type.
  • Adding validation constraints on an entity, a DTO, or a form field.
  • Different rules per context (registration vs profile) through validation groups.
  • Converting values with a data transformer or reacting with form events.
  • Writing a custom constraint, or a form spread across several steps.

Default workflow

  1. Put business constraints on the entity or DTO; keep form-level constraints for UI-only rules such as uploads.
  2. Build the form type with explicit field types and options.
  3. Split rules into validation groups when contexts differ.
  4. Add data transformers or PRE_SET_DATA/PRE_SUBMIT listeners only where the model and the view disagree.
  5. In the controller, check isSubmitted() && isValid() and pass the form itself to render().

Guardrails

  • Pass the form, not createView(), to render() so an invalid submit answers 422.
  • A transformer that cannot convert throws TransformationFailedException, it never returns garbage.
  • Do not duplicate the same constraint on the form and on the entity.
  • Multi-step flows and the custom violation mapper are recent: verify the installed Symfony version first.

Progressive disclosure

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

Output contract

  • Form types and the constraints they rely on, with their groups.
  • Transformers, listeners or custom constraints, each with a reason.
  • Tests for a valid submit, an invalid submit (422), and each custom constraint.

References

  • reference.md

Comments

Markdown supported