@naturalcycles/js-lib
Version:
Standard library for universal (browser + Node.js) javascript
48 lines (47 loc) • 1.96 kB
TypeScript
import type { ZodString } from 'zod';
import { z } from 'zod';
import type { IsoDate, UnixTimestamp, UnixTimestampMillis } from '../types.js';
type ZodBranded<T, B> = T & Record<'_zod', Record<'output', number & B>>;
export type ZodBrandedString<B> = ZodBranded<z.ZodString, B>;
export type ZodBrandedInt<B> = ZodBranded<z.ZodInt, B>;
export type ZodBrandedNumber<B> = ZodBranded<z.ZodNumber, B>;
declare function unixTimestamp(): ZodBrandedInt<UnixTimestamp>;
declare function unixTimestamp2000(): ZodBrandedInt<UnixTimestamp>;
declare function unixTimestampMillis(): ZodBranded<z.ZodNumber, UnixTimestampMillis>;
declare function unixTimestampMillis2000(): ZodBrandedInt<UnixTimestampMillis>;
declare function semVer(): z.ZodString;
declare function isoDate(): ZodBrandedString<IsoDate>;
declare function email(): z.ZodEmail;
declare function base62(): z.ZodString;
declare function base64(): z.ZodString;
declare function base64Url(): z.ZodString;
declare function jwt(): z.ZodString;
/**
* "Slug" - a valid URL, filename, etc.
*/
declare function slug(): z.ZodString;
declare function ianaTimezone(): z.ZodEnum;
type BaseDBEntityZodShape = {
id: ZodString;
created: ZodBrandedInt<UnixTimestamp>;
updated: ZodBrandedInt<UnixTimestamp>;
};
declare function dbEntity(): z.ZodObject<BaseDBEntityZodShape>;
declare function dbEntity<T extends z.ZodRawShape>(shape: T): z.ZodObject<BaseDBEntityZodShape & T>;
export declare const customZodSchemas: {
base62: typeof base62;
base64: typeof base64;
base64Url: typeof base64Url;
dbEntity: typeof dbEntity;
email: typeof email;
ianaTimezone: typeof ianaTimezone;
isoDate: typeof isoDate;
jwt: typeof jwt;
slug: typeof slug;
semver: typeof semVer;
unixTimestamp: typeof unixTimestamp;
unixTimestamp2000: typeof unixTimestamp2000;
unixTimestampMillis: typeof unixTimestampMillis;
unixTimestampMillis2000: typeof unixTimestampMillis2000;
};
export {};