#111 adds serialize/deserialize functions for compiled schemas. This issue would make it easy to serialize and restore a validator without having to use the low-level experimental API. This is what I'm thinking,
const validator = await validate("https://example.com/main");
const result1 = validator(42, "BASIC");
const json = validator.serialize();
const restoredValidator = restoreValidator(json);
const result2 = restoredValidator(42, "BASIC");
Is it too weird to have a function with properties? This is an interesting option because it allows for the possibility of validating both at runtime and when restored later without having to compile twice.
The alternative is to just have a dedicated function that serializes directly without building a validator function.
const json = await serializedValidator("https://example.com/main");
const restoredValidator = restoreValidator(json);
const result = restoredValidator(42, "BASIC");
#111 adds serialize/deserialize functions for compiled schemas. This issue would make it easy to serialize and restore a validator without having to use the low-level experimental API. This is what I'm thinking,
Is it too weird to have a function with properties? This is an interesting option because it allows for the possibility of validating both at runtime and when restored later without having to compile twice.
The alternative is to just have a dedicated function that serializes directly without building a validator function.