mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-08-16 12:31:43 +02:00
.config
.run
.workdir
Agent
Common
Docker
Server
Phantom.Server
Phantom.Server.Database
Phantom.Server.Database.Postgres
Phantom.Server.Minecraft
Phantom.Server.Rpc
Phantom.Server.Services
Phantom.Server.Web
Phantom.Server.Web.Bootstrap
Phantom.Server.Web.Components
Dialogs
Forms
Graphics
Tables
Utils
BlazorUtils.cs
BootstrapEditContext.cs
DebounceTimer.cs
EditContextExtensions.cs
FormCustomValidationAttribute.cs
FormValidationAttribute.cs
Throttler.cs
Phantom.Server.Web.Components.csproj
_Imports.razor
Phantom.Server.Web.Identity
Utils
.dockerignore
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
Directory.Build.props
Directory.Build.targets
Dockerfile
LICENSE
Packages.props
PhantomPanel.sln
README.md
global.json
18 lines
695 B
C#
18 lines
695 B
C#
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace Phantom.Server.Web.Components.Utils;
|
|
|
|
public abstract class FormValidationAttribute<TModel, TValue> : ValidationAttribute {
|
|
public sealed override bool IsValid(object? value) {
|
|
return base.IsValid(value);
|
|
}
|
|
|
|
protected sealed override ValidationResult? IsValid(object? value, ValidationContext validationContext) {
|
|
var model = (TModel) validationContext.ObjectInstance;
|
|
return value is TValue typedValue && IsValid(model, typedValue) ? ValidationResult.Success : new ValidationResult(null, new [] { FieldName });
|
|
}
|
|
|
|
protected abstract string FieldName { get; }
|
|
protected abstract bool IsValid(TModel model, TValue value);
|
|
}
|