about summary refs log tree commit diff
path: root/LibMatrix.DebugDataValidationApi/Controllers
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-08-14 04:26:27 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-08-14 04:26:27 +0200
commit8fdc48e5b21b1eea61534b181585858727500f34 (patch)
tree71cc2655ca1e2b5556c2c7c1ad550c5df6b499ef /LibMatrix.DebugDataValidationApi/Controllers
parentSplit LibMatrix into separate repo (diff)
downloadLibMatrix-bak-8fdc48e5b21b1eea61534b181585858727500f34.tar.xz
Move more projects over
Diffstat (limited to 'LibMatrix.DebugDataValidationApi/Controllers')
-rw-r--r--LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs b/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs
new file mode 100644

index 0000000..1599f35 --- /dev/null +++ b/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs
@@ -0,0 +1,26 @@ +using System.Text.Json; +using LibMatrix.Extensions; +using Microsoft.AspNetCore.Mvc; + +namespace LibMatrix.DebugDataValidationApi.Controllers; + +[ApiController] +[Route("/")] +public class ValidationController : ControllerBase { + private readonly ILogger<ValidationController> _logger; + + public ValidationController(ILogger<ValidationController> logger) { + _logger = logger; + } + + [HttpPost("/validate/{type}")] + public async Task<bool> Get([FromRoute] string type, [FromBody] JsonElement content) { + Type t = Type.GetType(type); + if (t is null) { + Console.WriteLine($"Type `{type}` does not exist!"); + throw new ArgumentException($"Unknown type {type}!"); + } + Console.WriteLine($"Validating {type}..."); + return content.FindExtraJsonElementFields(t, "$"); + } +}