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<typeof Index>
export type Order = t.Static<typeof OrderClause>
export type Group = t.Static<typeof GroupClause>

export type TrilogyOptions = t.Static<typeof TrilogyOptions>
export type ModelOptions = t.Static<typeof ModelOptions>
export type AggregateOptions = t.Static<typeof AggregateOptions>
export type CreateOptions = t.Static<typeof CreateOptions>
export type UpdateOptions = t.Static<typeof UpdateOptions>
export type FindOptions = t.Static<typeof FindOptions>