webmozarts / assert

Assertions to validate method input/output with nice error messages.
MIT License
7.56k stars 145 forks source link

Add validRegexPattern assertions #305

Open zlodes opened 3 weeks ago

zlodes commented 3 weeks ago

Why?

  1. PHP functions working with regex (preg_match, preg_replace, etc.) work in legacy way — they just return false instead of throwing exception.
  2. The way to check if the string is regex is quite hacky, so, would be great to hide the check implementation somewhere.

References

  1. https://stackoverflow.com/a/8825096/3578207
zlodes commented 3 weeks ago

I see that some tests failed. Fixing. 🤔