UNPKG

@tsed/schema-formio

Version:

Transform Ts.ED Schema & JsonSchema to a valid Formio schema

22 lines (17 loc) 639 B
export interface FormioMapper { (schema: any, options: any): any; } const FormioMappersContainer: Map<string, FormioMapper> = new Map(); export function registerFormioMapper(type: string, mapper: FormioMapper) { return FormioMappersContainer.set(type, mapper); } export function getFormioMapper(type: string): FormioMapper { // istanbul ignore next if (!FormioMappersContainer.has(type)) { throw new Error(`Formio ${type} mapper doesn't exists`); } return FormioMappersContainer.get(type)!; } export function execMapper(type: string, schema: any, options: any): any { return getFormioMapper(type)(schema, options); }