@prismicio/types-internal
Version:
Prismic types for Custom Types and Prismic Data
35 lines (30 loc) • 673 B
text/typescript
import * as t from "io-ts"
import {
StringFromBoolean,
StringFromNumber,
StringOrNull,
} from "../../../validators"
export const SelectFieldType = "Select"
export const SelectConfig = t.exact(
t.partial({
label: StringOrNull,
placeholder: t.string,
default_value: t.string,
options: t.readonlyArray(
t.union([t.string, StringFromNumber, StringFromBoolean]),
),
}),
)
export type SelectConfig = t.TypeOf<typeof SelectConfig>
export const Select = t.exact(
t.intersection([
t.type({
type: t.literal(SelectFieldType),
}),
t.partial({
fieldset: StringOrNull,
config: SelectConfig,
}),
]),
)
export type Select = t.TypeOf<typeof Select>