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

After mapping callback #71

Open
mabar opened this issue Aug 19, 2023 · 0 comments
Open

After mapping callback #71

mabar opened this issue Aug 19, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@mabar
Copy link
Member

mabar commented Aug 19, 2023

Description

It is easier and more type-safe to check dependencies between properties after object was fully mapped

    public function validate(): void {
        if (
            $this->status === Status::PAID && $this->paidAt === null
            || $this->status === Status::UNPAID && $this->paidAt !== null
        ) {
           throw ValueDoesNotMatch::createFromString('Payment date can only be set if and only if the status is `paid`.', Value::none());
        }
    }

Addition information

No response

Related issues

No response

@mabar mabar added the enhancement New feature or request label Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant