{"id":20163717,"url":"https://github.com/emik03/emik.analyzers.matches","last_synced_at":"2026-02-25T13:01:38.711Z","repository":{"id":164602423,"uuid":"630563576","full_name":"Emik03/Emik.Analyzers.Matches","owner":"Emik03","description":"Analyzer for compile-time parameter validation with the power of regex.","archived":false,"fork":false,"pushed_at":"2024-10-15T21:44:21.000Z","size":104,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T02:08:25.735Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Emik03.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Emik03","custom":"https://paypal.me/emik03"}},"created_at":"2023-04-20T16:42:38.000Z","updated_at":"2024-10-15T21:44:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"4407dcc6-3f8e-41be-bc61-1b6933f6a880","html_url":"https://github.com/Emik03/Emik.Analyzers.Matches","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Emik03%2FEmik.Analyzers.Matches","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Emik03%2FEmik.Analyzers.Matches/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Emik03%2FEmik.Analyzers.Matches/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Emik03%2FEmik.Analyzers.Matches/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Emik03","download_url":"https://codeload.github.com/Emik03/Emik.Analyzers.Matches/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233753981,"owners_count":18724922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T00:31:18.590Z","updated_at":"2025-09-21T12:33:03.928Z","avatar_url":"https://github.com/Emik03.png","language":"C#","funding_links":["https://github.com/sponsors/Emik03","https://paypal.me/emik03"],"categories":[],"sub_categories":[],"readme":"# Emik.Analyzers.Matches\n\n[![NuGet package](https://img.shields.io/nuget/v/Emik.Analyzers.Matches.svg?logo=NuGet)](https://www.nuget.org/packages/Emik.Analyzers.Matches)\n[![License](https://img.shields.io/github/license/Emik03/Emik.Analyzers.Matches.svg?style=flat)](https://github.com/Emik03/Emik.Analyzers.Matches/blob/main/LICENSE)\n\nAnalyzer for compile-time parameter validation with the power of regex.\n\nThis project has a dependency to [Emik.Morsels](https://github.com/Emik03/Emik.Morsels), if you are building this\nproject, refer to its [README](https://github.com/Emik03/Emik.Morsels/blob/main/README.md) first.\n\n---\n\n- [Example](#example)\n- [Lints](#lints)\n- [Contribute](#contribute)\n- [License](#license)\n\n---\n\n## Example\n\n```csharp\n[StringSyntax(StringSyntaxAttribute.Regex)]\nconst string ValidatorQuery = @\"^\\d{2}$\";\n\n[GeneratedRegex(ValidatorQuery)]\npartial Regex Validator();\n\nbyte? Test([Emik.Match(ValidatorQuery)] string x)\n{\n    if (!Validator().IsMatch(out var capture)) // OK\n        return null;\n\n    if (!Validator().IsMatch(out _, out var captureThatDoesNotExist)) // Error\n        return null;\n\n    if (!new Regex(x).IsMatch(out _)) // Warning: Not a constant\n        return null;\n\n    return byte.Parse(capture);\n}\n\nstring TestTyped(X x) =\u003e x.Value;\n\nrecord X(string Value)\n{\n    public static implicit operator X([Match(@\"^\\w{3}$\")] string value) =\u003e new(value);\n}\n\nTest(\"12\"); // OK\nTest(\"34\"); // OK\nTestTyped(\"foo\"); // OK\nTestTyped(\"bar\"); // OK\n\nTest(\"1\"); // Error\nTest(\"foobar\"); // Error\nTestTyped(\"12\"); // Error\nTestTyped(\"food\"); // Error\n\nTest(bool.FalseString); // Warning: Not a constant\nTestTyped(bool.TrueString); // Warning: Not a constant\n```\n\n## Lints\n\n| Id                                                                                             | Title                                                      |\n|------------------------------------------------------------------------------------------------|------------------------------------------------------------|\n| [EAM001](https://github.com/Emik03/Emik.Analyzers.Matches/tree/master/Documentation/EAM001.md) | Argument fails regex test                                  |\n| [EAM002](https://github.com/Emik03/Emik.Analyzers.Matches/tree/master/Documentation/EAM002.md) | Non-constant argument may fail regex test                  |\n| [EAM003](https://github.com/Emik03/Emik.Analyzers.Matches/tree/master/Documentation/EAM003.md) | Argument regex test took too long                          |\n| [EAM004](https://github.com/Emik03/Emik.Analyzers.Matches/tree/master/Documentation/EAM004.md) | Capture group doesn't exist                                |\n| [EAM005](https://github.com/Emik03/Emik.Analyzers.Matches/tree/master/Documentation/EAM005.md) | Missing out declaration for capture group                  |\n| [EAM006](https://github.com/Emik03/Emik.Analyzers.Matches/tree/master/Documentation/EAM006.md) | Non-constant Regex may have wrong number of capture groups |\n\n## Contribute\n\nIssues and pull requests are welcome to help this repository be the best it can be.\n\n## License\n\nThis repository falls under the [MPL-2 license](https://www.mozilla.org/en-US/MPL/2.0/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femik03%2Femik.analyzers.matches","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femik03%2Femik.analyzers.matches","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femik03%2Femik.analyzers.matches/lists"}