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

How to not auto-assign null to nullable properties? #113

Closed
eigan opened this issue May 1, 2022 · 3 comments
Closed

How to not auto-assign null to nullable properties? #113

eigan opened this issue May 1, 2022 · 3 comments

Comments

@eigan
Copy link

eigan commented May 1, 2022

I want to differentiate between user not supplying a property, and supplying null.

class Payload {
    // Must always be provided
    public int $id;
    
    // Can be null, or string,
    public string|null $note;
}

The source ['id' => 1] will set Payload::$note to null. But user
did not supply null as value. I want to handle this a MappingError and ask
user to supply either null or string. Is this possible somehow?

@romm
Copy link
Member

romm commented May 2, 2022

Hi @eigan, thanks for the report!

It looks like a valid usecase indeed; I'd link it to #3 which is next on my todo list.

@romm
Copy link
Member

romm commented Jun 17, 2022

Hi @eigan, #159 should fix this. Can you take a look and see if this is solved on your side?

@romm
Copy link
Member

romm commented Jun 23, 2022

Fixed with #159.

@romm romm closed this as completed Jun 23, 2022
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

No branches or pull requests

2 participants