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

Passing an enum to caster handle without an error #841

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

lkmadushan
Copy link
Contributor

@lkmadushan lkmadushan commented Aug 14, 2024

Allow to pass an enum to Structure::validateAndCreate method.

Previously below code didn't work.

Structure::validateAndCreate([
    'enum' => DummyBackedEnum::FOO
])

Some libraries (ex: Lighthouse PHP) which is a GraphQL implementation, sends Enum types through the request. I think we don't need to send the Enum string value again to the validate method. It should accept Enum types also.

@clementbirkle
Copy link
Contributor

I have the same issue with attributes that are collections of enums.

I get an error like: Object of class App\Enums\MyEnum could not be converted to string.

I think/hope that this PR should fix it as well.

@rubenvanassche
Copy link
Member

Thanks!

@rubenvanassche rubenvanassche merged commit 06fd7ce into spatie:main Oct 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants