Shape validation libraries?

I am looking for a library to help me parsed JSON data. I want to ensure they conform to certain type I have defined and extract those values.
There are two libraries that I found allow me to do this: tink_validation and dataclass, bot having their drawbacks.
tink_validation was a perfect fit, but it doesn’t work with types defined beforehand, only inlined. So this does not work:

typedef IncomingMessage = {
  final event:String;
  final context:String;
  final payload:{
    final coordinates:{
      final column:Int;
      final row:Int;
    final isInMultiAction:Bool;
    final settings:{
      final id:String;
      final remoteServer:String;

function parseMessage(message:String):IncomingMessage {
  final parsed = hammerspoon.Json.decode(message);
  final value:IncomingMessage = Validation.extract(parsed);

On the other Hand, dataclass requires you to define specific classes to deal with the validation, and I don’t want that, I just want simple data structures.

Is there anything like tink_validation that works well with types defined with typedef?

I think tink_json and json2object does that.
json2object example from my code:

// better to create once
final jsonParser = new JsonParser<IncomingMessage>();
final msg = jsonParser.fromJson(dataString);
if (jsonParser.errors.length > 0) {...}

Yes, they do, and I starting looking at them. However, they come with their own JSON parsing library, which makes my output file to grow from ~800 to more than 2k
But, because I can’t use Haxe Serialization classes (they force a dep I can’t afford), and they make my output to grow that much anyway I’m moving to json2object for now.
I really wish jsonn2object forced me to check a Result output, rather than manually having to check for errors.
Is it possible to make them just validate already parsed objects?

Wait, what is wrong with tink_validation in your example? As far as I understand it should work

Gives me the following errors:

/usr/local/lib/haxe/lib/tink_validation/0,2,0/src/tink/validation/macro/Macro.hx:44: characters 35-47 : Class<tink.validation.macro.GenExtractor> should be tink.typecrawler.GeneratorProvider
/usr/local/lib/haxe/lib/tink_validation/0,2,0/src/tink/validation/macro/Macro.hx:44: characters 35-47 : ... For function argument 'gen'
/usr/local/lib/haxe/lib/tink_validation/0,2,0/src/tink/validation/macro/Macro.hx:78: characters 35-47 : Class<tink.validation.macro.GenValidator> should be tink.typecrawler.GeneratorProvider
/usr/local/lib/haxe/lib/tink_validation/0,2,0/src/tink/validation/macro/Macro.hx:78: characters 35-47 : ... For function argument 'gen'
src/streamDeckButton/Messages.hx:63: characters 52-58 : Unknown<0> cannot be constructed

Are you using latest git head for all the tink libs?

No, I just install them from haxelib. In this case I tried 0.11.0 I think

That’s usually not a good way to use tink libs, you might want to try their git version

Ok, I’ll give that a try. I guess all I need to do is put the git clone url in place of the version string ?

haxelib git [lib name] [lib repo] should do yeah (lib repo can be the ssh git clone uri)

By the way, why is it like that with tink libraries ? Why aren’t they up to date in haxelib?

Tink people barely use haxelib, that’s some side effect of using lix I suppose