1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2024-11-24 04:42:56 +01:00
Minecraft-Phantom-Panel/Server/Phantom.Server.Web.Components/Utils/FormValidationAttribute.cs

17 lines
615 B
C#

using System.ComponentModel.DataAnnotations;
namespace Phantom.Server.Web.Components.Utils;
public abstract class FormValidationAttribute : ValidationAttribute {
public sealed override bool IsValid(object? value) {
return base.IsValid(value);
}
protected sealed override ValidationResult? IsValid(object? value, ValidationContext validationContext) {
return IsValid(validationContext.ObjectInstance, value) ? ValidationResult.Success : new ValidationResult(null, new [] { FieldName });
}
protected abstract string FieldName { get; }
protected abstract bool IsValid(object model, object? value);
}