using FluentValidation; namespace Mizuki.Validators; /// /// The validator for uploaded form files. /// public class FormFileValidator : AbstractValidator { /// /// Constructs the rule set for the FormFileValidator. /// public FormFileValidator() { const int MiB = 1024 * 1024; RuleFor(f => f.Length) .LessThan(50 * MiB); RuleFor(f => f.FileName) .NotEmpty(); RuleFor(f => f.FileName) .Matches(@"^(?!\s)(?!.*\s$)[^<>:""/\\|?*\x00-\x1F]+\.(?!\.)[^<>:""/\\|?*\x00-\x1F]{1,4}$|^(?!\s)(?!.*\s$)[^<>:""/\\|?*\x00-\x1F]+$"); } }