Skip to content

Instantly share code, notes, and snippets.

View matthewsinex's full-sized avatar

Matthew Sinex matthewsinex

View GitHub Profile
@matthewsinex
matthewsinex / FileAttribute.cs
Created April 30, 2018 19:18
ASP.NET Core Multiple File Upload Validation
public class FileAttribute : ValidationAttribute
{
public string[] FileTypes { get; set; }
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
if (value is IFormFile)
{
return ValidateSingleFile((IFormFile)value);
}
else if (value is IEnumerable<IFormFile>)
@matthewsinex
matthewsinex / FileAttribute.cs
Last active April 30, 2018 19:10
ASP.NET MVC 5 Custom File DataAnnotation
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace TestProjectMVC5.Models
{
public class FileAttribute : ValidationAttribute
{