How to use the runtypes.Boolean 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 hmil / rest.ts / test / fixtures / DTOs.ts View on Github external
import * as rt from 'runtypes';

export const QueryParamsResponse = rt.Record({
    query1: rt.String,
    query2: rt.Boolean
});

export const TodoItemType = rt.Union(
    rt.Literal('housekeeping'),
    rt.Literal('work'),
    rt.Literal('shopping')
);

export const TodoItem = rt.Record({
    title: rt.String,
    done: rt.Boolean,
    type: TodoItemType
});


export const SavedTodoItem = rt.Intersect(
    TodoItem,
    rt.Record({
        id: rt.String
    })
);

export const SimpleMessage = rt.Record({
    message: rt.String
});

export const PathData = rt.Record({
github citycide / trilogy / src / types.ts View on Github external
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
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