UNPKG

macoolka-io

Version:

`macoolka-io` is Runtime type system for IO decoding/encoding.

54 lines (53 loc) 1.54 kB
import * as t from 'io-ts'; import { Reader } from 'fp-ts/Reader'; import { Message } from 'macoolka-i18n/lib/i18nFormat'; export declare type I18NType<A, O, I> = Reader<{ formatMessage: (option: Message<any>) => string; }, t.Type<A, O, I>>; export declare type I18NTypeMessage<A, O, I> = Reader<{ formatMessage: (option: Message<any>) => string; }, string>; interface NumberValidate { /** * The value must less than given value * @desczh * 字段的最大值 * @since 0.2.0 */ maximum?: number; /** * The value must great than given value * @desczh * 字段的最小值 * @since 0.2.0 */ minimum?: number; message?: string; } export declare const typeNumber: ({ maximum, minimum, message }: NumberValidate) => I18NType<number, number, unknown>; interface StringValidate { /** * The length of value must great than given value * @desczh * 字段的最小长度 * @since 0.2.0 */ minLength?: number; /** * The length of value must less than given value * @desczh * 字段的最大长度 * @since 0.2.0 */ maxLength?: number; /** * The length value must match the given pattern * @desczh * 字段必须匹配这个正则表达式 * @since 0.2.0 */ pattern?: string; message?: string; } export declare const typeString: ({ maxLength: _maxLength, minLength: _minLength, pattern, message }: StringValidate) => I18NType<string, string, unknown>; export {};