How to use the runtypes.Partial 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 jschr / vscodethemes / types / runtime.ts View on Github external
}).And(
  // Optional properties.
  Partial({
    displayName: String.Or(Null),
    shortDescription: String.Or(Null),
    repositoryUrl: String.Or(Null),
  }),
)

export const PackageJSONRuntime = Record({
  contributes: Record({
    themes: Array(
      Record({
        path: String,
      }).And(
        Partial({
          label: String,
          uiTheme: String,
        }),
      ),
    ),
  }),
})

export const ThemeTypeRuntime = Union(
  Literal('light'),
  Literal('dark'),
  Literal('hc'),
)

export const ColorsRuntime = Partial({
  // These colors may not exist in the object but also may be null.
github jschr / vscodethemes / types / runtime.ts View on Github external
Partial({
          label: String,
          uiTheme: String,
        }),
      ),
    ),
  }),
})

export const ThemeTypeRuntime = Union(
  Literal('light'),
  Literal('dark'),
  Literal('hc'),
)

export const ColorsRuntime = Partial({
  // These colors may not exist in the object but also may be null.
  activityBarBackground: String.Or(Null),
  activityBarForeground: String.Or(Null),
  activityBarBorder: String.Or(Null),
  statusBarBackground: String.Or(Null),
  statusBarForeground: String.Or(Null),
  editorBackground: String.Or(Null),
  editorForeground: String.Or(Null),
  editorGroupHeaderTabsBackground: String.Or(Null),
  editorLineNumberForeground: String.Or(Null),
  tabActiveBackground: String.Or(Null),
  tabActiveForeground: String.Or(Null),
  tabInactiveBackground: String.Or(Null),
  tabInactiveForeground: String.Or(Null),
  editorGroupHeaderTabsBorder: String.Or(Null),
  tabActiveBorder: String.Or(Null),
github citycide / trilogy / src / types.ts View on Github external
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
})

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

export type TrilogyOptions = t.Static
github citycide / trilogy / src / types.ts View on Github external
t.Tuple(t.String, t.String)
)

export const TrilogyOptions = t.Partial({
  client: t.Union(t.Literal('sqlite3'), t.Literal('sql.js')),
  dir: t.String
})

export const ModelOptions = t.Partial({
  index: Index,
  primary: t.Array(t.String),
  unique: t.Array(t.String),
  timestamps: t.Boolean
})

export const AggregateOptions = t.Partial({
  distinct: t.Boolean,
  group: GroupClause,
  order: OrderClause
})

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

export const FindOptions = t.Partial({
  limit: t.Number,
  order: OrderClause,
  random: t.Boolean,
  raw: t.Boolean,
  skip: t.Number
})
github citycide / trilogy / src / types.ts View on Github external
order: OrderClause
})

export const CreateOptions = t.Partial({
  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,
github citycide / trilogy / src / types.ts View on Github external
export const GroupClause = t.Union(
  t.String,
  t.Array(t.String)
)

export const OrderClause = t.Union(
  t.String,
  t.Tuple(t.String, t.String)
)

export const TrilogyOptions = t.Partial({
  client: t.Union(t.Literal('sqlite3'), t.Literal('sql.js')),
  dir: t.String
})

export const ModelOptions = t.Partial({
  index: Index,
  primary: t.Array(t.String),
  unique: t.Array(t.String),
  timestamps: t.Boolean
})

export const AggregateOptions = t.Partial({
  distinct: t.Boolean,
  group: GroupClause,
  order: OrderClause
})

export const CreateOptions = t.Partial({
  raw: t.Boolean
})
github typeetfunc / runtypes-generate / src / custom.spec.ts View on Github external
const MemberWithRole = role => Record({
    role,
    fio: Fio
  }).And(
    Partial({
      dependant: Boolean.Or(Void)
    })
  )
  const Spouse = MemberWithRole(Literal('spouse'))
github citycide / trilogy / src / types.ts View on Github external
t.String,
  t.Array(t.Union(t.String, t.Array(t.String))),
  t.Dictionary(t.Union(t.String, t.Array(t.String)))
)

export const GroupClause = t.Union(
  t.String,
  t.Array(t.String)
)

export const OrderClause = t.Union(
  t.String,
  t.Tuple(t.String, t.String)
)

export const TrilogyOptions = t.Partial({
  client: t.Union(t.Literal('sqlite3'), t.Literal('sql.js')),
  dir: t.String
})

export const ModelOptions = t.Partial({
  index: Index,
  primary: t.Array(t.String),
  unique: t.Array(t.String),
  timestamps: t.Boolean
})

export const AggregateOptions = t.Partial({
  distinct: t.Boolean,
  group: GroupClause,
  order: OrderClause
})
github typeetfunc / runtypes-generate / src / custom.spec.ts View on Github external
describe('FamilyObject', () => {
  const StringOrVoid = String.Or(Void)
  const Fio = Partial({
    firstname: StringOrVoid,
    lastname: StringOrVoid,
    middlename: StringOrVoid
  })
  const MemberWithRole = role => Record({
    role,
    fio: Fio
  }).And(
    Partial({
      dependant: Boolean.Or(Void)
    })
  )
  const Spouse = MemberWithRole(Literal('spouse'))
  const NotSpouse = MemberWithRole(Union(
    Literal('sibling'),
    Literal('child'),