foliojs/restructure

Assertions

timkurvers opened this issue · 2 comments

Would it be convenient to have some sort of assertion type?

new r.Struct(
  version: new r.Assert(uint8, 3, 'Only version 3.x is supported')
)

Or should that be handled in userland for structs using the postProcess hook?

If you use versioned structs you'll get an error for unsupported versions.

Ah yes, of course! What about verifying a signature?

GIF = new r.Struct(
  signature: new r.Assert(new r.String(3), 'GIF')
  # ...
)