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

Need chaining assertions with allow fails. #117

Open
Lexty opened this issue Aug 26, 2015 · 0 comments
Open

Need chaining assertions with allow fails. #117

Lexty opened this issue Aug 26, 2015 · 0 comments

Comments

@Lexty
Copy link
Contributor

Lexty commented Aug 26, 2015

It may look like

\Assert\ThatOneOf($someObject, 'Value must be string or object with method "__toString".')
    ->string()
    ->methodExists($someObject, '__toString')
    ->end();

This chain fails only if both assertions fails.
I know this check can be realize as it described in #83.

try {
    Assert::string($someObject);
} catch (AssertionFailedException $e) {
    Assert::methodExists($someObject, '__toString');
}

But if we need more assertions next looks better.

\Assert\ThatOneOf($x, '-30 < x < -20 || -10 < x < 10 || 20 < x < 30 || 40 < x < 50')
    ->range(-30, -20)
    ->range(-10,  10)
    ->range( 20,  30)
    ->range( 40,  50)
    ->end();

What do you think about it?

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