How to use the superstruct.struct.list 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 vuejs / vue-component-compiler / src / assemble.js View on Github external
render: {
    id: struct.union(['string?', 'null']),
    code: struct.union(['string?', 'null']),
    map: 'object?',
    descriptor: struct.union(['object', 'null'])
  },
  styles: struct.list([
    {
      id: struct.union(['string?', 'null']),
      code: struct.union(['string?', 'null']),
      map: 'object?',
      modules: 'object?',
      descriptor: struct.union(['object', 'null'])
    }
  ]),
  customBlocks: struct.list([
    {
      id: 'string?',
      code: 'string?',
      map: 'object?',
      descriptor: struct.union(['object', 'null'])
    }
  ])
})

const Config = any =>
  defaultsdeep(
    struct({
      esModule: 'boolean?',
      require: 'object?',
      scopeId: 'string?',
      moduleIdentifier: 'string?',
github jxnblk / figma-theme / index.js View on Github external
lineHeight: 'number',
    })
  ]),
  fonts: 'array',
  fontSizes: 'array',
  fontWeights: 'array',
  lineHeights: 'array',
  metadata: 'object?'
})

const Data = struct.partial({
  name: 'string',
  lastModified: 'string',
  thumbnailUrl: 'string',
  document: struct.partial({
    children: struct.list([ 'object' ]),
  }),
  styles: struct.dict([
    'string',
    struct.partial({
      name: 'string',
      styleType: 'string',
    })
  ])
})

const unique = arr => [...new Set(arr)]

module.exports = (data, opts = {}) => {
  Data(data)
  const {
    styles = {},
github vuejs / vue-component-compiler / src / assemble.js View on Github external
}

const Source = struct({
  script: {
    id: struct.union(['string?', 'null']),
    code: struct.union(['string?', 'null']),
    map: 'object?',
    descriptor: struct.union(['object', 'null'])
  },
  render: {
    id: struct.union(['string?', 'null']),
    code: struct.union(['string?', 'null']),
    map: 'object?',
    descriptor: struct.union(['object', 'null'])
  },
  styles: struct.list([
    {
      id: struct.union(['string?', 'null']),
      code: struct.union(['string?', 'null']),
      map: 'object?',
      modules: 'object?',
      descriptor: struct.union(['object', 'null'])
    }
  ]),
  customBlocks: struct.list([
    {
      id: 'string?',
      code: 'string?',
      map: 'object?',
      descriptor: struct.union(['object', 'null'])
    }
  ])