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

Assertions with info about which class/property is invalid #266

Open
arjanfrans opened this issue Mar 30, 2022 · 0 comments
Open

Assertions with info about which class/property is invalid #266

arjanfrans opened this issue Mar 30, 2022 · 0 comments

Comments

@arjanfrans
Copy link

arjanfrans commented Mar 30, 2022

I have extended webmozart/assert's code for my use case in which I want to know more detailed information about assertions. I do assertions inside my entities and would always like to know which entity and which property is invalid.

The implementation looks like this:

// Pass a string as "root" identifier 
            Assert::that('User', 'name', $nameValue)
                ->startsWith('Test')
                ->notEmpty();


// Or pass the object
            Assert::that($user, 'name', $nameValue)
                ->startsWith('Test')
                ->notEmpty();

As you can see, I implemented an "assertion chain" here as well to avoid repeating the ::that(..) call.

Is this something that you can imagine being integrated into this library, or is this use case too specific? If yes, I'd be open to provide a PR.

@arjanfrans arjanfrans changed the title Assertions with info about which class/property is invalid. Assertions with info about which class/property is invalid Mar 30, 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

1 participant