Complex object validation with Symfony Validator

I have an object (a person) which is being edited (and validated) over several forms:

  • personal data form
    • first name
    • last name
    • file input for photo upload
  • account data form
    • email
  • publishing form
    • can publish only if all required fields have been filled

What I need is to have validations that I can use per-form and also for the whole person, e.g the errors would be:

  • personal data form – “please fill your first name”, …
  • whole person – “please fill your personal data”, …

If I define validations in Entity, there might still be some rules that are form-only (file upload, password repeat); it seems kinda wrong anyway because I might have different rules for web form and for API. Then again if I define validations in Form classes, then the rules are scattered around, also how can I initiate validation without form submission (which seems a hackish thing to do anyway).

Most elegant solution seems to me a separate validator which I can divide into validation groups and call it per-form and for whole object. How to do that using compound validator so that I can use other validators?

Or is there another way? Thank you.

Symfony verson is 6.