public CreativeDoohVideoCreateViewModelValidator(ILifetimeScope container, ICreativeSettings creativeSettings) { RuleFor(x => x.CreativeSizeId) .Must(id => { using (var scope = container.BeginLifetimeScope()) { var sizes = scope.Resolve <ICreativeSizeService>().GetDoohCreativeSizes(); return(sizes.Any(x => x.CreativeSizeId == id)); } }) .When(x => x.CreativeSizeId.HasValue) .WithMessage("{PropertyName} is an invalid dooh creative size id."); RuleFor(x => x.File.MediaType) .Must(VideoContentTypes.Contains) .When(x => x.File != null) .WithMessage(VideoFileErrorMessage); RuleFor(x => x.File.FileName) .Must(fileName => VideoFileExtensions.Contains(Path.GetExtension(fileName)?.ToLower())) .When(x => x.File != null) .WithMessage(VideoFileErrorMessage); RuleFor(x => x.File.Buffer) .Must(x => x.Length <= creativeSettings.MaxDoohVideoSizeInKb * 1024) .When(x => x.File != null && creativeSettings.MaxDoohVideoSizeInKb > 0) // set MaxDoohFileSizeInKb zero to bypass size checking .WithMessage($"Uploaded file size exceeds {creativeSettings.MaxDoohVideoSizeInKb}KB limit."); }
public VastParser(IVastService vastService, ICreativeSettings creativeSettings) { _vastService = vastService; _creativeSettings = creativeSettings; Logger = NullLogger.Instance; }
public CreativeSwiffyCreateViewModelValidator(ICreativeSettings creativeSettings) { RuleFor(x => x.ImpressionUrl) .Matches(creativeSettings.RegexBeaconUrl); RuleFor(x => x.File.MediaType) .Equal("text/html") .When(x => x.File != null) .WithMessage("Uploaded file must be swiffy html."); }
public CreativeCreateViewModelValidator(ICreativeSettings creativeSettings) { RuleFor(x => x.ImpressionUrl) .Matches(creativeSettings.RegexBeaconUrl); RuleFor(x => x.File.MediaType) .Must(ValidateMediaType) .When(x => x.File != null) .WithMessage("Uploaded file must be image or flash."); }
public CreativeHtml5CreateViewModelValidator(ICreativeSettings creativeSettings) { RuleFor(x => x.ImpressionUrl) .Matches(creativeSettings.RegexBeaconUrl); RuleFor(x => x.File.MediaType) .Must(ZipContentTypes.Contains) .When(x => x.File != null) .WithMessage("Uploaded file must be zip html5."); RuleFor(x => x.File.FileName) .Must(x => x != null && x.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)) .When(x => x.File != null) .WithMessage("Uploaded file must be zip html5."); }
public CreativeDoohCreateViewModelValidator(ILifetimeScope container, ICreativeSettings creativeSettings) { RuleFor(x => x.CreativeSizeId) .Must(id => { using (var scope = container.BeginLifetimeScope()) { var sizes = scope.Resolve <ICreativeSizeService>().GetDoohCreativeSizes(); return(sizes.Any(x => x.CreativeSizeId == id)); } }) .When(x => x.CreativeSizeId.HasValue) .WithMessage("{PropertyName} is an invalid dooh creative size id."); RuleFor(x => x.File.MediaType) .Must(ImageContentTypes.Contains) .When(x => x.File != null) .WithMessage("Uploaded file must be image(gif, png, or jpeg)."); RuleFor(x => x.File.Buffer) .Must(x => x.Length <= creativeSettings.MaxDoohImageSizeInKb * 1024) .When(x => x.File != null && creativeSettings.MaxDoohImageSizeInKb > 0) // set MaxDoohFileSizeInKb zero to bypass size checking .WithMessage($"Uploaded file size exceeds {creativeSettings.MaxDoohImageSizeInKb}KB limit."); }
public CreativePatchViewModelValidator(ICreativeSettings creativeSettings) { RuleFor(x => x.ImpressionUrl) .Matches(creativeSettings.RegexBeaconUrl); }