Skip to content
New issue

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

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

Already on GitHub? # to your account

Feature property morphable validation #1

Open
wants to merge 5 commits into
base: feature-property-morphable
Choose a base branch
from

Conversation

bentleyo
Copy link
Owner

@bentleyo bentleyo commented Jan 29, 2025

This PR fixes the problems identified in spatie#921 (comment).

I've achieved this by doing the following:

  • Requiring a #[PropertyForMorph] attribute to be added to property-morphable properties
    • By doing this it allows us to add validation messages if the concrete version of the data class cannot be determined
    • It also allows us to restrict the properties passed into morph and only run it if they are all available
  • Casting properties when validating
    • This allows us to use more complex types e.g. enums or values with defaults for morphable properties without having to worry if the provided value has been cast already or not

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant