UNPKG

@sprucelabs/schema

Version:

Static and dynamic binding plus runtime validation and transformation to ensure your app is sound. 🤓

29 lines (28 loc) • 1.3 kB
import { FieldSubclass } from '../fields/field.static.types'; export interface FieldRegistration { /** The type that is used as the key to the enum */ type: string; /** The package that defined this field */ package: string; /** The name of this class based on class reference */ className: string; /** Pulls the description off the field */ description: string; /** How should this field be imported (SpruceSchema) */ importAs: string; /** The type mapper responsible for handling SchemaValues mapping of schema to interface of values */ valueTypeMapper?: string; } export interface FieldRegistrationOptions { /** The package that defined this field, like @sprucelabs/schema */ package: string; /** The type that is used as the key to the enum, auto PascalCased */ type: string; /** A reference to the class of the field */ class: FieldSubclass<any>; /** How should this field be imported (import * as {{importAs}} from {{package}}) */ importAs: string; } export declare function validateFieldRegistration(registration: FieldRegistration): asserts registration is FieldRegistration; /** Register a new type of field */ export default function registerFieldType(options: FieldRegistrationOptions): FieldRegistration;