I discovered that it's possilbe to define complex data schemes in Nim, and 
being able to validate it against Nim types.

The problem is that it's validated only at runtime. Is there a way to make it 
to be type-safe and validated at compile time?

Example, in the code below, there's a mistake, the `name` defined as `int` not 
as `string`. Is it possible to make it fail at compile time? The `jinit` is 
macro that does the magic.
    
    
    macro jinit*[T](TT: type[T], x: untyped): T =
      let jobject = toJoImpl(x)
      quote do:
        `jobject`.json_to(`TT`)
    
    type Unit = object
      name: string
    
    echo Unit.jinit { name: 1 } # Error, name is int instead of string
    
    
    Run

Check [playground](https://play.nim-lang.org/#ix=3rt0) for full code.

Reply via email to