< Summary

Information
Class: MyNet.UI.ViewModels.Export.FileExportViewModelValidator<T>
Assembly: MyNet.UI
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/ViewModels/Export/FileExportViewModelValidator.cs
Tag: 323_28699572109
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 36
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()0%4260%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/ViewModels/Export/FileExportViewModelValidator.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="FileExportViewModelValidator.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using FluentValidation;
 8using MyNet.Observable;
 9using MyNet.UI.Resources;
 10
 11namespace MyNet.UI.ViewModels.Export;
 12
 13/// <summary>
 14/// FluentValidation rules for <see cref="FileExportViewModelBase{T}"/>.
 15/// </summary>
 16/// <typeparam name="T">The exported item type.</typeparam>
 17public class FileExportViewModelValidator<T> : AbstractValidator<FileExportViewModelBase<T>>
 18{
 19    /// <summary>
 20    /// Initializes a new instance of the <see cref="FileExportViewModelValidator{T}"/> class.
 21    /// </summary>
 022    public FileExportViewModelValidator()
 23    {
 024        Include(new ExportViewModelValidator<T>());
 25
 026        RuleFor(x => x.Destination)
 027            .NotEmpty()
 028            .WithRequiredLocalizedMessage(nameof(FileExportViewModelBase<>.Destination));
 29
 030        RuleFor(x => x.Destination)
 031            .Must((vm, destination) => vm.FileType.IsValidPath(destination!))
 032            .When(x => !string.IsNullOrWhiteSpace(x.Destination))
 033            .WithMessage(_ => MessageResources.FileHasInvalidExtensionError);
 034    }
 35}
 36

Methods/Properties

.ctor()