Skip to content

Move validation logic to the Version class #7155

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

Merged
merged 7 commits into from
Apr 28, 2025

Conversation

bastianallgeier
Copy link
Member

@bastianallgeier bastianallgeier commented Apr 23, 2025

Reasoning

We want to be able to validate individual versions before publishing them.

Changelog

Enhancements from previous betas

  • New Version::errors() method
  • New Version::isValid() method, which is now used in ModelWithContent::isValid() instead of the Form class.

Refactoring

  • Switch to PHPUnit Attributes in VersionTest and ModelWithContentTest
  • New ModelWithContent::isValid unit tests

Breaking changes

None

Docs

Ready?

  • In-code documentation (wherever needed)
  • Unit tests for fixed bug/feature
  • Tests and CI checks all pass

For review team

  • Add changes & docs to release notes draft in Notion

@bastianallgeier bastianallgeier force-pushed the v5/refactoring/version-errors branch from 5f17e70 to 70b6480 Compare April 23, 2025 08:46
Copy link
Member

@distantnative distantnative left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to also add Version::isValid($language).

@bastianallgeier
Copy link
Member Author

@distantnative 👍 while refactoring this, I realized that we have two different ways to validate between ModelWithContent::isValid() and ModelWithContent::errors() 🙈 In ::errors we go through all sections and also collect errors from sections without fields. (e.g. for pages with a max or min) and in ::isValid we only validate the content. Not sure what to do with that and if we should already tackle it here as well.

@bastianallgeier bastianallgeier force-pushed the v5/refactoring/version-errors branch from ea53aa7 to d107db5 Compare April 23, 2025 09:56
@bastianallgeier bastianallgeier marked this pull request as ready for review April 23, 2025 10:08
@bastianallgeier bastianallgeier added this to the 5.0.0-rc.1 milestone Apr 23, 2025
Copy link
Member

@distantnative distantnative left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bastianallgeier This is indeed a weird split between ModelWithContent::errors() and ModelWithContent::isValid(). But it has been weird like this before, so no need to fix that right now with this PR.

@bastianallgeier bastianallgeier merged commit 1f4efae into v5/develop Apr 28, 2025
12 checks passed
@bastianallgeier bastianallgeier deleted the v5/refactoring/version-errors branch April 28, 2025 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants