How to use the superstruct.struct.interface function in superstruct

To help you get started, we’ve selected a few superstruct 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 saberland / saber / packages / saber / src / utils / validateConfig.ts View on Github external
export function validateConfig(
  config: SaberConfig,
  { dev }: { dev: boolean }
): ValidatedSaberConfig {
  const siteConfig = struct.interface(
    {
      title: 'string?',
      description: 'string?'
    },
    {}
  )

  // Type of Saber plugins
  const plugins = struct.union(
    [
      ['string'],
      [
        {
          resolve: 'string',
          options: 'object?'
        }
github saberland / saber / packages / saber / src / utils / validateConfig.ts View on Github external
const markdown = struct(
    {
      slugify: 'string?',
      options: 'object?',
      headings: 'object?',
      highlighter: 'string?',
      lineNumbers: 'boolean?',
      // Same as the type of Saber plugins
      plugins
    },
    {
      plugins: []
    }
  )

  const themeConfig = struct.interface({}, {})

  const permalinks = struct.union(['object', 'function'], {})

  const server = struct(
    {
      host: 'string?',
      port: 'number?'
    },
    {
      host: '0.0.0.0',
      port: 3000
    }
  )

  const build = struct(
    {
github panva / node-oidc-provider / schemas / structs / cookies / index.js View on Github external
const { struct } = require('superstruct');
const names = require('./names');
const options = require('./options');
const {
  cookies:
  {
    keys,
    long,
    short,
    thirdPartyCheckUrl,
  },
} = require('../../../lib/helpers/defaults');

module.exports = struct.interface({
  names,
  thirdPartyCheckUrl: 'string & webUri',
  long: options(long),
  short: options(short),
  keys: ['string'],
}, {
  names: {},
  short: {},
  long: {},
  keys,
  thirdPartyCheckUrl,
});