< Summary

Information
Class: MyNet.Observable.Validation.Validators.BoundedValueValidator<T>
Assembly: MyNet.Observable
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Observable/Validation/Validators/BoundedValueValidator.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 28
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
.ctor(...)100%44100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Observable/Validation/Validators/BoundedValueValidator.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="BoundedValueValidator.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System.Numerics;
 8using FluentValidation;
 9
 10namespace MyNet.Observable.Validation.Validators;
 11
 12/// <summary>
 13/// FluentValidation rules for <see cref="BoundedValue{T}"/>.
 14/// </summary>
 15/// <typeparam name="T">The numeric type.</typeparam>
 16public sealed class BoundedValueValidator<T> : AbstractValidator<BoundedValue<T>>
 17    where T : struct, INumber<T>
 18{
 19    /// <summary>
 20    /// Initializes a new instance of the <see cref="BoundedValueValidator{T}"/> class.
 21    /// </summary>
 22    /// <param name="propertyDisplayKey">Translation key used as the field name in messages.</param>
 6623    public BoundedValueValidator(string propertyDisplayKey) => RuleFor(x => x.Value)
 3324        .Must((model, value) => model.Range.Contains(value!.Value))
 3325        .When(x => x.Value.HasValue)
 3326        .WithMessage((model, _) => model.BuildRangeValidationMessage(propertyDisplayKey));
 27}
 28

Methods/Properties

.ctor(System.String)