< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Command.Input.Validation.UpdatePersonCommandValidator
Assembly: ArturRios.Heimdall.Command
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Command/Input/Validation/UpdatePersonCommandValidator.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 31
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage
100%
Covered methods: 1
Fully covered methods: 1
Total methods: 1
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%44100%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Application/ArturRios.Heimdall.Command/Input/Validation/UpdatePersonCommandValidator.cs

#LineLine coverage
 1using ArturRios.Heimdall.Domain.Enums;
 2using ArturRios.Heimdall.Shared.Messages;
 3using FluentValidation;
 4
 5namespace ArturRios.Heimdall.Command.Input.Validation;
 6
 7/// <summary>
 8///     Shape validation for <see cref="UpdatePersonCommand" /> (UC-08 step 2). Business rules that
 9///     need data access — existence, authorization, email uniqueness, scope ownership — are enforced
 10///     by the handler.
 11/// </summary>
 12public class UpdatePersonCommandValidator : AbstractValidator<UpdatePersonCommand>
 13{
 4114    public UpdatePersonCommandValidator()
 15    {
 4116        RuleFor(command => command.Name)
 4117            .NotEmpty().WithMessage(PersonMessages.NameRequired)
 4118            .MaximumLength(200).WithMessage(PersonMessages.NameTooLong);
 19
 4120        RuleFor(command => command.Email)
 4121            .NotEmpty().WithMessage(PersonMessages.EmailRequired)
 4122            .EmailAddress().WithMessage(PersonMessages.EmailInvalid);
 23
 24        // The role is optional: null means "leave it unchanged". When supplied it must name one of
 25        // the three defined roles; whether the transition is *allowed* is the handler's decision.
 4126        RuleFor(command => command.RoleId)
 827            .Must(role => role is (int)Roles.SystemAdmin or (int)Roles.ScopeAdmin or (int)Roles.User)
 4128            .When(command => command.RoleId is not null)
 4129            .WithMessage(PersonMessages.UnknownRole);
 4130    }
 31}

Methods/Properties

.ctor()