How to use the hyper-ts.decodeParams function in hyper-ts

To help you get started, we’ve selected a few hyper-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 DenisFrezzato / hyper-ts-fastify / test / index.ts View on Github external
it('should validate all params (success case)', () => {
        const m = H.decodeParams(t.interface({ foo: t.number }).decode)
        const c = new MockConnection(new MockRequest({ foo: 1 }))
        return assertSuccess(m, c, { foo: 1 }, [])
      })
github DenisFrezzato / hyper-ts-fastify / test / index.ts View on Github external
it('should validate all params (failure case)', () => {
        const m = H.decodeParams(t.interface({ foo: t.number }).decode)
        const c = new MockConnection(new MockRequest({ foo: 'a' }))
        return assertFailure(m, c, errors => {
          assert.deepStrictEqual(failure(errors), [
            'Invalid value "a" supplied to : { foo: number }/foo: number',
          ])
        })
      })
    })