webmozarts / assert

Assertions to validate method input/output with nice error messages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ENHANCEMENT] miss a notOneOf()

meshenka opened this issue · comments

or basically the ability to just negate any assertion

Will try to submit a PR soon

Could this be clarified more?

one time i got a use case where i need value is not one in an array. As oneOf() throws an exception we could not just do !oneOf()

May be it is too an edge case IDY, but notOneOf() could be nice or functionnal style negation

or functionnal style Assert::Not().oneOf()

Does it help?

I've played around with the idea of lazy/combined assertions, in a style like this:

Assert::either(
    Type::string(),
    Type::null()
)($input);

I put something together here https://github.com/BackEndTea/Assert but its not a perfect state, and it doesn't deal properly with static analysis.

Assert::either(
    Type::string(),
    Type::null()
)($input);

ooooooh, please don't

@BackEndTea are you planning to pursue it?