How to use the io-ts.success 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 tangdrew / fhir-ts / packages / primitives / src / R4 / date.ts View on Github external
  (m, c) => (isDate(m) ? success(m) : failure(m, c)),
  identity
github tangdrew / fhir-ts / packages / primitives / src / R4 / base64Binary.ts View on Github external
  (m, c) => (isBase64Binary(m) ? success(m) : failure(m, c)),
  identity
github tangdrew / fhir-ts / packages / primitives / src / R4 / id.ts View on Github external
  (m, c) => (isId(m) ? success(m) : failure(m, c)),
  identity
github teamdigitale / io-functions / lib / utils / types.ts View on Github external
(s, c) => {
      if (s instanceof Set && arrayType.is(Array.from(s))) {
        return t.success(s);
      }
      if (arrayType.is(s)) {
        return t.success(new SerializableSet(Array.from(s)));
      }
      return t.failure(s, c);
    },
    t.identity
github unmock / unmock-js / packages / unmock-core / src / nock.ts View on Github external
(input, context) =>
    isMaybe(input) ? io.success(input) : io.failure(input, context),
  io.identity,
github celo-org / celo-monorepo / packages / contractkit / src / identity / claims / types.ts View on Github external
either.chain(t.string.validate(input, context), (stringValue) => {
      try {
        JSON.parse(stringValue)
        return t.success(stringValue)
      } catch (error) {
        return t.failure(stringValue, context, 'can not be parsed as JSON')
      }
    }),
  String
github gcanti / io-ts-types / src / Date / date.ts View on Github external
      (u, c) => (this.is(u) ? t.success(u) : t.failure(u, c)),
      t.identity
github witnet / sheikah / app / common / runtimeTypes / storage / wallets.ts View on Github external
t.string.validate(input, context).chain(keyPath => {
      let res: t.Validation>
      try {
        res = t.success(CryptoKeyPath.fromString(keyPath))
      } catch (e) {
        res = t.failure(keyPath, context)
      }

      return res
    }),
  /** encode: converts a value of type Array to string */
github teamdigitale / io-functions / lib / utils / types.ts View on Github external
(s, c) => {
      if (s instanceof Set && arrayType.is(Array.from(s))) {
        return t.success(s);
      }
      if (arrayType.is(s)) {
        return t.success(new SerializableSet(Array.from(s)));
      }
      return t.failure(s, c);
    },
    t.identity
github gcanti / io-ts-types / src / Date / DateFromNumber.ts View on Github external
(u, c) => {
        const validation = t.number.validate(u, c)
        if (validation.isLeft()) {
          return validation as any
        } else {
          const n = validation.value
          const d = new Date(n)
          return isNaN(d.getTime()) ? t.failure(n, c) : t.success(d)
        }
      },
      a => a.getTime()