< Summary

Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 53
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: SecretNameRegex()100%11100%
File 2: IsValid(...)100%44100%
File 2: Normalize(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Secrets/obj/Release/net10.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs

File '/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Secrets/obj/Release/net10.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs' does not exist (any more).

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Secrets/Services/DefaultSecretNameValidator.cs

#LineLine coverage
 1using System.Text.RegularExpressions;
 2
 3namespace Elsa.Secrets.Services;
 4
 5public partial class DefaultSecretNameValidator : ISecretNameValidator
 6{
 7    public bool IsValid(string? name, out string? error)
 8    {
 379        if (string.IsNullOrWhiteSpace(name))
 10        {
 111            error = "Secret name is required.";
 112            return false;
 13        }
 14
 3615        if (!SecretNameRegex().IsMatch(name.Trim()))
 16        {
 317            error = "Secret name must be 2-200 characters, start with a letter, and contain only letters, numbers, dots,
 318            return false;
 19        }
 20
 3321        error = null;
 3322        return true;
 23    }
 24
 5125    public string Normalize(string name) => name.Trim().ToLowerInvariant();
 26
 27    [GeneratedRegex("^[A-Za-z][A-Za-z0-9._:-]{1,199}$", RegexOptions.Compiled)]
 28    private static partial Regex SecretNameRegex();
 29}