Bearbeitung von Fragen

This commit is contained in:
2020-06-10 13:23:29 +02:00
parent 6d84a4614b
commit a8b04a6443
11 changed files with 205 additions and 34 deletions

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace MultipleChoiceTrainer.Validation
{
public class NotNullOrEmptyAttribute : ValidationAttribute
{
public NotNullOrEmptyAttribute()
{
}
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
if (value == null)
return new ValidationResult($"{validationContext.DisplayName} darf nicht leer sein!");
if (string.IsNullOrEmpty(value.ToString()) || string.IsNullOrWhiteSpace(value.ToString()))
{
return new ValidationResult($"{validationContext.DisplayName} darf nicht leer sein!");
}
return ValidationResult.Success;
}
}
}