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 assert that a value is string or integer? #83

Closed
sagikazarmark opened this issue Jan 8, 2015 · 3 comments
Closed

How to assert that a value is string or integer? #83

sagikazarmark opened this issue Jan 8, 2015 · 3 comments

Comments

@sagikazarmark
Copy link

Numeric is not an option, because it cannot be float.

@terah
Copy link

terah commented Feb 11, 2015

Maybe this?

\Assert\that($mVal)
    ->numeric("Must be an int or string")
    ->false(is_float($mVal), "Can't be a float.");

@mdavis1982
Copy link
Contributor

@terah I don't think that will work... Won't that validate that the value is numeric and false? I think in this case you'd need to run two separate assertions to make this possible:

try {
    Assert::string($value);
} catch (AssertionFailedException $e) {
    Assert::integer($value);
}

@sagikazarmark
Copy link
Author

@mdavis1982 ended up doing it, thanks.

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

3 participants