Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced StructValidator to unpack validation errors for structs #452

Merged
merged 12 commits into from
Nov 20, 2024

Conversation

Steveb-p
Copy link
Contributor

@Steveb-p Steveb-p commented Nov 14, 2024

🎫 Issue N/A

Description:

This PR introduces StructWrapperValidator (which implements ValidatorInterface from Symfony).

It is intended to decorate Symfony's Validator and unpack errors coming from struct assertions. This means it does not require any additional processing on the side of services, as long as the structs are packed using either the provided wrapper abstract, or the wrapper interface.

Before:
image

After:
image

image

For QA:

Documentation:

@adamwojs
Copy link
Member

Could you please open counterpart PR in ibexa/collaboration?

@Steveb-p
Copy link
Contributor Author

Could you please open counterpart PR in ibexa/collaboration?

If you wish to, sure. On it.

@Steveb-p
Copy link
Contributor Author

@konradoboza Added one additional change: 84ee00f

When working on ibexa/collaboration, I realized that the developer needs to always remember to mark struct as @Assert\Valid (using annotation/attribute/YAML).
So I've added this annotation to the ValidationStructWrapperInterface::getStruct() method, which makes Validator to assume that the object returned has to be valid (which makes sense, right?).
This uncovered the fact that, when done this way, struct. will always be the right prefix to use (as we're not relying on a property name anymore). So it made ValidationStructWrapperInterface::getStructName() no longer needed for anything.

Copy link

sonarcloud bot commented Nov 19, 2024

@Steveb-p Steveb-p merged commit c38bd01 into 4.6 Nov 20, 2024
21 checks passed
@Steveb-p Steveb-p deleted the validator branch November 20, 2024 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants