diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 04:26:27 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 04:26:27 +0200 |
commit | 8fdc48e5b21b1eea61534b181585858727500f34 (patch) | |
tree | 71cc2655ca1e2b5556c2c7c1ad550c5df6b499ef /LibMatrix.DebugDataValidationApi/Controllers | |
parent | Split LibMatrix into separate repo (diff) | |
download | LibMatrix-8fdc48e5b21b1eea61534b181585858727500f34.tar.xz |
Move more projects over
Diffstat (limited to '')
-rw-r--r-- | LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs | 26 |
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, "$"); + } +} |