@prismicio/types-internal
Version:
Prismic types for Custom Types and Prismic Data
31 lines (26 loc) • 708 B
text/typescript
import * as t from "io-ts"
import { NumberFromString } from "io-ts-types/lib/NumberFromString"
import { StringOrNull } from "../../../validators"
export const RangeFieldType = "Range"
export const RangeConfig = 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 RangeConfig = t.TypeOf<typeof RangeConfig>
export const Range = t.exact(
t.intersection([
t.type({
type: t.literal(RangeFieldType),
}),
t.partial({
fieldset: StringOrNull,
config: RangeConfig,
}),
]),
)
export type Range = t.TypeOf<typeof Range>