How to use the runtypes.Function function in runtypes

To help you get started, we’ve selected a few runtypes 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 citycide / trilogy / src / types.ts View on Github external
})

export const ColumnKind = t.Union(t.String, t.Function).withConstraint(value => {
  const type = isFunction(value) ? value.name : String(value)
  return type.toLowerCase() in ColumnTypes
}, { name: 'ColumnKind' })

export const ColumnDescriptor = t.Partial({
  defaultTo: t.Unknown,
  index: t.String,
  notNullable: t.Boolean,
  nullable: t.Boolean,
  primary: t.Boolean,
  unique: t.Boolean,
  type: ColumnKind,
  get: t.Function,
  set: t.Function
})

export type Index = t.Static
export type Order = t.Static
export type Group = t.Static

export type TrilogyOptions = t.Static
export type ModelOptions = t.Static
export type AggregateOptions = t.Static
export type CreateOptions = t.Static
export type UpdateOptions = t.Static
export type FindOptions = t.Static
export type ColumnKind = t.Static
export type ColumnDescriptor = t.Static
github citycide / trilogy / src / types.ts View on Github external
raw: t.Boolean
})

export const FindOptions = t.Partial({
  limit: t.Number,
  order: OrderClause,
  random: t.Boolean,
  raw: t.Boolean,
  skip: t.Number
})

export const UpdateOptions = t.Partial({
  raw: t.Boolean
})

export const ColumnKind = t.Union(t.String, t.Function).withConstraint(value => {
  const type = isFunction(value) ? value.name : String(value)
  return type.toLowerCase() in ColumnTypes
}, { name: 'ColumnKind' })

export const ColumnDescriptor = t.Partial({
  defaultTo: t.Unknown,
  index: t.String,
  notNullable: t.Boolean,
  nullable: t.Boolean,
  primary: t.Boolean,
  unique: t.Boolean,
  type: ColumnKind,
  get: t.Function,
  set: t.Function
})
github citycide / trilogy / src / types.ts View on Github external
export const ColumnKind = t.Union(t.String, t.Function).withConstraint(value => {
  const type = isFunction(value) ? value.name : String(value)
  return type.toLowerCase() in ColumnTypes
}, { name: 'ColumnKind' })

export const ColumnDescriptor = t.Partial({
  defaultTo: t.Unknown,
  index: t.String,
  notNullable: t.Boolean,
  nullable: t.Boolean,
  primary: t.Boolean,
  unique: t.Boolean,
  type: ColumnKind,
  get: t.Function,
  set: t.Function
})

export type Index = t.Static
export type Order = t.Static
export type Group = t.Static

export type TrilogyOptions = t.Static
export type ModelOptions = t.Static
export type AggregateOptions = t.Static
export type CreateOptions = t.Static
export type UpdateOptions = t.Static
export type FindOptions = t.Static
export type ColumnKind = t.Static
export type ColumnDescriptor = t.Static

export type SchemaRaw  = {