@sprucelabs/schema
Version:
Static and dynamic binding plus runtime validation and transformation to ensure your app is sound. 🤓
17 lines (16 loc) • 622 B
TypeScript
import { FieldDefinition } from './field.static.types';
export type SelectValue = string | number;
export interface SelectChoice {
/** Machine readable way to identify this choice */
value: SelectValue;
label: string;
}
export interface SelectFieldOptions {
choices: SelectChoice[];
}
export type SelectFieldValueTypeMapper<F extends SelectFieldDefinition> = F['options']['choices'][number]['value'];
export type SelectFieldDefinition = FieldDefinition<string, string, string[], string[]> & {
/** * .Select - A way to chose between a choices */
type: 'select';
options: SelectFieldOptions;
};