Skip to content

Add type validation to regex constraint #4492

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

Merged
merged 2 commits into from
Oct 11, 2023

Conversation

RenderMichael
Copy link
Contributor

@RenderMichael RenderMichael commented Oct 10, 2023

Fixes #4484
tests like

Assert.That(1, Does.Not.Match("[A-Z]"));
Assert.That((string?)null, Does.Not.Match("[A-Z]"));

will no longer pass.

Bonus performance for converting regex.Match(...).Success to regex.IsMatch(...)

Bonus performance for converting `regex.Match(...).Success` to `regex.IsMatch(...)`
Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @RenderMichael Your code changes are functionally fine.
My nitpicks are purely to get a more consistent code base.

@RenderMichael
Copy link
Contributor Author

@manfred-brands thanks for the review! feedback merged, PTAL

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that. Nothing further.

@manfred-brands manfred-brands merged commit 8e73942 into nunit:master Oct 11, 2023
@RenderMichael RenderMichael deleted the regex branch March 9, 2024 07:25
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

Successfully merging this pull request may close these issues.

String not-regex constraint succeeds non-string actual value
2 participants