How to use the @requestnetwork/data-format.isKnownFormat function in @requestnetwork/data-format

To help you get started, we’ve selected a few @requestnetwork/data-format examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RequestNetwork / requestNetwork / packages / request-client.js / src / api / content-data-extension.ts View on Github external
public createExtensionsDataForCreation(content: any): any {
    if (DataFormat.isKnownFormat(content)) {
      const { valid, errors } = DataFormat.validate(content);

      if (!valid) {
        const errorsToShow = errors.map((e: any) => JSON.stringify(e)).join('\n');
        throw new Error(
          `The content data seem to follow a request format but contains errors: ${errorsToShow}`,
        );
      }
    }

    return this.extension.createCreationAction({ content });
  }

@requestnetwork/data-format

Data format for the Request Network protocol.

MIT
Latest version published 2 months ago

Package Health Score

84 / 100
Full package analysis