2.0.0 • Published 1 year ago

@await-to/zod v2.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@await-to/zod

Install

npm i @await-to/chainable
npm i @await-to/zod

Example

import { to, OkResult } from '@await-to/chainable';
import { awaitToZod } from '@await-to/zod';
import { z } from 'zod';

const schema = z
	.object({
		test: z.string(),
	})
	.transform((current) => {
		return Number(current.test);
	});

const result = await to(Promise.resolve({ test: 123 }))
	.and(awaitToZod(schema))
	.get();

if (result.ok) {
	result.data; // data is number
}