How to use the runtypes.String 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 / testAPI.ts View on Github external
simplePatch: PATCH `/method/patch`
        .body(SimpleMessage)
        .response(rt.String),

    simpleDelete: DELETE `/method/delete`
        .response(rt.String),

    noTemplateString: GET('/path/string')
        .response(rt.String),

    simpleQueryParams: GET `/query`
        .query(rt.Record({
            'mandatory': rt.String,
            'union': rt.Union(rt.Literal('true'), rt.Literal('false')),
            'optional': rt.Union(rt.String, rt.Undefined)
        }))
        .response(QueryParamsResponse),

    optionalQueryParams: GET `/query/optional`
        .query({
            'maybeParam': '' as string | undefined
        }),

    simpleRequestBody: POST `/simpleBody`
        .body(TodoItem)
        .response(SavedTodoItem),

    noRepsonseEndpoint: PUT `/noResponse`,

    pathParams: GET `/path/${'kind'}/id/${'id'}`
        .response(PathData),
github citycide / trilogy / src / types.ts View on Github external
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
})

export const CreateOptions = t.Partial({