UNPKG

@prismicio/types-internal

Version:
31 lines (26 loc) 718 B
import * as t from "io-ts" import { NumberFromString } from "io-ts-types/lib/NumberFromString" import { StringOrNull } from "../../../validators" export const NumberFieldType = "Number" export const NumberConfig = t.exact( t.partial({ label: StringOrNull, placeholder: t.string, min: t.union([t.number, NumberFromString]), max: t.union([t.number, NumberFromString]), step: t.union([t.number, NumberFromString]), }), ) export type NumberConfig = t.TypeOf<typeof NumberConfig> export const Number = t.exact( t.intersection([ t.type({ type: t.literal(NumberFieldType), }), t.partial({ fieldset: StringOrNull, config: NumberConfig, }), ]), ) export type Number = t.TypeOf<typeof Number>