How to use the io-ts.string function in io-ts

To help you get started, we’ve selected a few io-ts 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 maasglobal / maas-schemas / maas-schemas-ts / src / maas-backend / customers / verification / initiate / request.ts View on Github external
import * as t from 'io-ts';
import * as Units_ from 'maas-schemas-ts/core/components/units';
import * as ApiCommon_ from 'maas-schemas-ts/core/components/api-common';

type Defined =
  | Record
  | Array
  | string
  | boolean
  | number
  | null;
const Defined = t.union([
  t.UnknownRecord,
  t.UnknownArray,
  t.string,
  t.boolean,
  t.number,
  t.null,
]);

export const schemaId =
  'http://maasglobal.com/maas-backend/customers/verification/initiate/request.json';

// Request
// The default export. More information at the top.
export type Request = t.Branded<
  {
    customerId?: Units_.IdentityId;
    headers?: ApiCommon_.Headers;
    identityId?: Units_.IdentityId;
    payload?: {
github AugurProject / augur / packages / augur-node / src / server / getters / get-dispute-tokens.ts View on Github external
import * as t from "io-ts";
import Knex from "knex";
import { formatBigNumberAsFixed } from "../../utils/format-big-number-as-fixed";
import { BigNumber, DisputeTokensRowWithTokenState, ReportingState, UIDisputeTokenInfo, UIDisputeTokens } from "../../types";
import { reshapeDisputeTokensRowToUIDisputeTokenInfo } from "./database";

export const DisputeTokenState = t.keyof({
  ALL: null,
  UNCLAIMED: null,
  UNFINALIZED: null,
});

export const DisputeTokensParams = t.type({
  universe: t.string,
  account: t.string,
  stakeTokenState: t.union([DisputeTokenState, t.null, t.undefined]),
});

export async function getDisputeTokens(db: Knex, augur: {}, params: t.TypeOf) {
  const query: Knex.QueryBuilder = db.select(["payouts.*", "disputes.crowdsourcerId as disputeToken", "balances.balance", "market_state.reportingState"]).from("disputes");
  query.join("markets", "markets.marketId", "crowdsourcers.marketId");
  query.leftJoin("market_state", "markets.marketStateId", "market_state.marketStateId");
  query.leftJoin("blocks", "markets.creationBlockNumber", "blocks.blockNumber");
  query.join("crowdsourcers", "crowdsourcers.crowdsourcerId", "disputes.crowdsourcerId");
  query.join("payouts", "payouts.payoutId", "crowdsourcers.payoutId");
  query.join("balances", "crowdsourcers.crowdsourcerId", "balances.token");
  query.where("universe", params.universe).where("disputes.reporter", params.account).where("balances.balance", ">", 0).where("balances.owner", params.account);
  if (params.stakeTokenState == null || params.stakeTokenState === "ALL") {
    // currently, do nothing, leaving this in case we want to flavor how we group or present response
  } else if (params.stakeTokenState === "UNFINALIZED") {
github gcanti / io-ts-codegen / test / fixtures / expected.ts View on Github external
import * as t from 'io-ts'

export type Health = {
  /** Name of the service. */
  id: string,
  /** Version of the service. */
  version: string,
  /** Current UTC date and time of the request, in ISO 8601 format. */
  currentAsOfUtc: string
}

export const Health = t.interface({
  /** Name of the service. */
  id: t.string,
  /** Version of the service. */
  version: t.string,
  /** Current UTC date and time of the request, in ISO 8601 format. */
  currentAsOfUtc: t.string
})

export type ICQAlertCategory =
  | 'Critical'
  | 'Alert'
  | 'Notification'

export const ICQAlertCategory = t.keyof({
  Critical: true,
  Alert: true,
  Notification: true
})

export type ICQAlert = {
github AugurProject / augur / packages / augur-sdk / src / state / getter / Liquidity.ts View on Github external
import { Augur } from '../../index';
import * as _ from 'lodash';

export const Order = t.type({
    price: t.string,
    amount: t.string,
});
  
export const OutcomeOrderBook = t.type({
    bids: t.array(Order),
    asks: t.array(Order),
});


export const OrderBook = t.dictionary(
    t.string,
    OutcomeOrderBook,
);

export const GetMarketLiquidityRankingParams = t.type({
    orderBook: OrderBook,
    numTicks: t.string,
    marketType: t.number,
    reportingFeeDivisor: t.string,
    feePerCashInAttoCash: t.string,
    numOutcomes: t.number,
    spread: t.number,
});

export interface MarketLiquidityRanking {
    marketRank: number;
    totalMarkets: number;
github elastic / kibana / x-pack / legacy / plugins / infra / common / http_api / metadata_api.ts View on Github external
id: rt.string,
  name: rt.string,
});

export const InfraMetadataProjectRT = rt.partial({
  id: rt.string,
});

export const InfraMetadataMachineRT = rt.partial({
  interface: rt.string,
});

export const InfraMetadataCloudRT = rt.partial({
  instance: InfraMetadataInstanceRT,
  provider: rt.string,
  availability_zone: rt.string,
  project: InfraMetadataProjectRT,
  machine: InfraMetadataMachineRT,
});

export const InfraMetadataInfoRT = rt.partial({
  cloud: InfraMetadataCloudRT,
  host: InfraMetadataHostRT,
});

const InfraMetadataRequiredRT = rt.type({
  name: rt.string,
  features: rt.array(InfraMetadataFeatureRT),
});

const InfraMetadataOptionalRT = rt.partial({
  info: InfraMetadataInfoRT,
github elastic / kibana / x-pack / legacy / plugins / fleet / server / repositories / agents / types.ts View on Github external
export type AgentActionType = t.TypeOf;

export const RuntimeAgentActionData = t.interface(
  {
    type: RuntimeAgentActionType,
  },
  'AgentActionData'
);

export const RuntimeAgentAction = t.intersection([
  RuntimeAgentActionData,
  t.interface(
    {
      id: t.string,
      created_at: t.string,
    },
    'AgentAction'
  ),
  t.partial({
    data: t.string,
    sent_at: t.string,
  }),
]);

export type AgentType = t.TypeOf;

const newAgentProperties = {
  type: RuntimeAgentType,
  active: t.boolean,
};
github mAAdhaTTah / brookjs / packages / brookjs-cli / src / cli / RC.ts View on Github external
t.union([t.string, t.tuple([t.string, t.object])])
      ),
      transformIgnorePatterns: t.array(t.string),
      watchPathIgnorePatterns: t.array(t.string)
    })
  ),
  webpack: t.partial({
    modifier: t.Function,
    entry: t.union([
      t.string,
      t.dictionary(t.string, t.string),
      t.array(t.string)
    ]),
    output: t.type({
      path: t.string,
      filename: t.union([t.Function, t.string])
    })
  })
});

type RCBase = t.TypeOf;

type WebpackBase = Required['webpack'];

type WebpackState = {
  env: Required['mode'];
  cmd: 'build' | 'start';
};

type Webpack = Omit & {
  modifier?: (
    config: webpack.Configuration,
github witnet / sheikah / app / common / runtimeTypes / wallet / index.ts View on Github external
(self) => t.union([
    t.nullType,
    t.number,
    t.string,
    t.boolean,
    t.array(self),
    t.dictionary(t.string, self),
  ])
)
github mAAdhaTTah / brookjs / packages / brookjs-cli / src / cli / Command.tsx View on Github external
import React from 'react';
import yargs, { Argv, Arguments } from 'yargs';
import * as t from 'io-ts';
import { RCResult } from './RC';
import { Maybe } from './util';

export const Command = t.type({
  builder: t.Function,
  cmd: t.string,
  describe: t.string,
  View: t.Function
});

type CommandBase = Omit, 'builder' | 'View'>;
type Builder<a> = (yargs: Argv</a><a>) =&gt; Argv</a><a>;

export interface Command</a><a> extends CommandBase {
  builder: Builder</a><a>;
  View: React.ComponentType&lt;{
    args: Arguments</a><a>;
    rc: Maybe;
    cwd: string;
  }&gt;;
}

export class Commands {</a>
github devexperts / swagger-codegen-ts / src / swagger.ts View on Github external
get: createOptionFromNullable(OperationObject),
	put: createOptionFromNullable(OperationObject),
	post: createOptionFromNullable(OperationObject),
	delete: createOptionFromNullable(OperationObject),
	options: createOptionFromNullable(OperationObject),
	head: createOptionFromNullable(OperationObject),
	patch: createOptionFromNullable(OperationObject),
	parameters: createOptionFromNullable(t.array(t.union([ParameterObject, ReferenceObject]))),
});

export type TPathsObject = TDictionary;
export const PathsObject: t.Type = t.dictionary(t.string, PathItemObject);

export type TParametersDefinitionsObject = TDictionary;
export const ParametersDefinitionsObject: t.Type = t.dictionary(
	t.string,
	ParameterObject,
);

export type TResponsesDefinitionsObject = TDictionary;
export const ResponsesDefinitionsObject: t.Type = t.dictionary(
	t.string,
	ResponseObject,
);

export type TScopesObject = TDictionary;
export const ScopesObject: t.Type = t.dictionary(t.string, t.string);

//#region SecuritySchemeObject

export type TBaseSecuritySchemeObjectProps = {
	description: Option;