< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowInstances.BulkCancel.RequestValidator
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/BulkCancel/RequestValidator.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 25
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%210%
ValidCombination(...)0%4260%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/BulkCancel/RequestValidator.cs

#LineLine coverage
 1using Elsa.Common.Models;
 2using FastEndpoints;
 3using FluentValidation;
 4
 5namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.BulkCancel;
 6
 7/// <summary>
 8/// Validates the request for bulk canceling workflow instances.
 9/// </summary>
 10public class RequestValidator : Validator<Request>
 11{
 12    /// <inheritdoc />
 013    public RequestValidator()
 14    {
 015        RuleFor(x => x.VersionOptions)
 016            .Must((request, options) => ValidCombination(request.DefinitionId, options))
 017            .WithMessage("VersionOptions and DefinitionId should either both be empty or both be not empty");
 018    }
 19
 20    private bool ValidCombination(string? definitionId, VersionOptions? options)
 21    {
 022        return (definitionId is null && options is null)
 023               || (definitionId is not null && options is not null);
 24    }
 25}