import { type IFormatValidator } from "https://deno.land/x/earthstar@v9.3.3/src/entries/npm.ts";
Validators are each responsible for one document format such as "es.4". They are used by Storage instances to check if documents are valid before accepting them and sign new documents.
Properties
The string name of the format, like "es.4"
Methods
Deterministic hash of this version of the document
Add an author signature to the document. The input document needs a signature field to satisfy Typescript, but it will be overwritten here, so you may as well just set signature: '' on the input. Return a copy of the original document with the signature field changed, or return a ValidationError.
Return a copy of the doc without extra fields, plus the extra fields as a separate object. If the input is not a plain javascript object, return a ValidationError. This should be run before checkDocumentIsValid. The output doc will be more likely to be valid once the extra fields have been removed.
This calls all the more detailed functions which start with underscores. Returns true if the document is ok.