How to use the runtypes.Tuple 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
lastUpdated: String,
  publishedDate: String,
  releaseDate: String,
  publisher: PublisherRuntime,
  versions: Array(VersionRuntime),
  statistics: Array(StatisticRuntime),
}).And(
  // Optional properties.
  Partial({
    displayName: String,
    shortDescription: String,
  }),
)

export const ExtensionQueryResultsRuntime = Record({
  results: Tuple(Record({ extensions: Array(ExtensionRuntime) })),
})

export const ScrapeExtensionsPayloadRuntime = Record({
  page: Number,
})

export const ExtractThemesPayloadRuntime = Record({
  extensionId: String,
  extensionName: String,
  publisherName: String,
  lastUpdated: Number,
  publishedDate: Number,
  releaseDate: Number,
  packageUrl: String,
  installs: Number,
  rating: Number,
github pelotom / runtypes / examples / src / space-game.ts View on Github external
Number,
  String,
  Literal,
  Array,
  Tuple,
  Record,
  Dictionary,
  Union,
  Static,
  match,
} from 'runtypes';

const NonNegative = Number.withConstraint(n => n >= 0);
type NonNegative = Static; // = number

const Vector = Tuple(Number, Number, Number);
type Vector = Static; // = [number, number, number]

const Asteroid = Record({
  type: Literal('asteroid'),
  location: Vector,
  mass: NonNegative,
});
type Asteroid = Static<
  typeof Asteroid
>; /* = {
  type: 'asteroid';
  location: Vector;
  mass: NonNegative;
}*/

const Planet = Record({
github citycide / trilogy / src / types.ts View on Github external
| CriteriaListNormalized

export const Index = t.Union(
  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,
github typeetfunc / runtypes-generate / src / index.spec.ts View on Github external
describe('SpaceObject', () => {
    const Vector = Tuple(Number, Number, Number)

    const Asteroid = Record({
        type: Literal('asteroid'),
        location: Vector,
        mass: Number,
    })

    const Planet = Record({
        type: Literal('planet'),
        location: Vector,
        mass: Number,
        population: Number,
        habitable: Boolean,
    })

    const Rank = Union(