< Summary - ZhEaIsNsAaBn.Libraries coverage (affected: 23 packages)

Information
Class: ZhEaIsNsAaBn.Utilities.ValidationResponses.ValidationResponse<T>
Assembly: ZhEaIsNsAaBn.Utilities.ValidationResponses
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/UtilitiesPackages/ZhEaIsNsAaBn.Utilities.ValidationResponses/ValidationResponseOfT.cs
Line coverage
60%
Covered lines: 12
Uncovered lines: 8
Coverable lines: 20
Total lines: 77
Line coverage: 60%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
FromValidation(...)100%11100%
op_Implicit(...)100%11100%
op_Implicit(...)100%210%
op_Implicit(...)100%210%
op_Implicit(...)100%11100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/UtilitiesPackages/ZhEaIsNsAaBn.Utilities.ValidationResponses/ValidationResponseOfT.cs

#LineLine coverage
 1#region Usings
 2using System.Diagnostics.CodeAnalysis;
 3#endregion
 4
 5namespace ZhEaIsNsAaBn.Utilities.ValidationResponses;
 6
 7/// <summary>
 8///     Represents a generic validation response that extends <see cref="ValidationResponse" /> to include typed data.
 9///     Provides validation functionality along with the ability to carry validated data of type T.
 10/// </summary>
 11/// <typeparam name="T">The type of data being validated and carried in the response.</typeparam>
 12public class ValidationResponse< T > : ValidationResponse
 13{
 14    /// <summary>
 15    ///     Gets or sets the data row or object being validated.
 16    /// </summary>
 17    /// <value>The data of type T that was validated; <see langword="default"/> when created from errors only.</value>
 18    public T? Row { get; set; }
 19
 20    /// <summary>
 21    ///     Creates a new <see cref="ValidationResponse{T}" /> from an existing <see cref="ValidationResponse" />,
 22    ///     copying the validation errors but without setting the Row property.
 23    /// </summary>
 24    /// <param name="validation">The validation response to copy errors from.</param>
 25    /// <returns>A new <see cref="ValidationResponse{T}" /> instance with the same errors.</returns>
 26    [ SuppressMessage( "Design", "CA1000:Do not declare static members on generic types",
 27                       Justification = "Factory on the generic response, same house pattern as LayerResponse<T> (STYLE_G
 28    public static ValidationResponse<T> FromValidation( ValidationResponse validation ) =>
 329        new()
 330            {
 331                Errors = validation.Errors
 332            };
 33
 34    /// <summary>
 35    ///     Implicitly converts a value of type T to a <see cref="ValidationResponse{T}" /> with no validation errors.
 36    /// </summary>
 37    /// <param name="value">The value to convert.</param>
 38    /// <returns>A new <see cref="ValidationResponse{T}" /> instance containing the specified value with no errors.</ret
 39    public static implicit operator ValidationResponse<T>( T value ) =>
 1240        new()
 1241            {
 1242                Row = value
 1243            };
 44
 45    /// <summary>
 46    ///     Implicitly converts a list of validation errors to a <see cref="ValidationResponse{T}" />.
 47    /// </summary>
 48    /// <param name="errors">The list of validation errors to convert.</param>
 49    /// <returns>A new <see cref="ValidationResponse{T}" /> instance containing the specified errors.</returns>
 50    public static implicit operator ValidationResponse<T>( List<ColumnValidationError> errors ) =>
 051        new()
 052            {
 053                Errors = errors
 054            };
 55
 56    /// <summary>
 57    ///     Implicitly converts an array of validation errors to a <see cref="ValidationResponse{T}" />.
 58    /// </summary>
 59    /// <param name="errors">The array of validation errors to convert.</param>
 60    /// <returns>A new <see cref="ValidationResponse{T}" /> instance containing the specified errors.</returns>
 61    public static implicit operator ValidationResponse<T>( ColumnValidationError[] errors ) =>
 062        new()
 063            {
 064                Errors = errors.ToList()
 065            };
 66
 67    /// <summary>
 68    ///     Implicitly converts a single validation error to a <see cref="ValidationResponse{T}" />.
 69    /// </summary>
 70    /// <param name="errors">The validation error to convert.</param>
 71    /// <returns>A new <see cref="ValidationResponse{T}" /> instance containing the specified error.</returns>
 72    public static implicit operator ValidationResponse<T>( ColumnValidationError errors ) =>
 673        new()
 674            {
 675                Errors = [errors]
 676            };
 77}