blob: 81753d1a07f36cb065c66ca6cb5bca9201930dca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
using System.Text.Json;
using LibMatrix.Extensions;
using Microsoft.AspNetCore.Mvc;
namespace LibMatrix.DebugDataValidationApi.Controllers;
[ApiController]
[Route("/")]
public class ValidationController(ILogger<ValidationController> logger) : ControllerBase {
private readonly ILogger<ValidationController> _logger = logger;
[HttpPost("/validate/{type}")]
public Task<bool> Get([FromRoute] string type, [FromBody] JsonElement content) {
var 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 Task.FromResult(content.FindExtraJsonElementFields(t, "$"));
}
}
|