UNPKG

sveltekit-superforms-5

Version:

<p align="center"> <img src="https://github.com/ciscoheat/sveltekit-superforms/raw/main/logo.svg" width="150px" align="center" alt="Superforms logo" /> <h1 align="center">Superforms 💥</h1> <p align="center">Making SvelteKit forms a pleasure to use!

26 lines (25 loc) • 781 B
// eslint-disable-next-line @typescript-eslint/no-unused-vars const commonConverter = (description, converters) => { const jsonSchema = {}; jsonSchema.type = description.type; if (description.nullable) { jsonSchema.type = [jsonSchema.type, 'null']; } if (description.oneOf?.length > 0) { jsonSchema.enum = description.oneOf; } if (description.notOneOf?.length > 0) { jsonSchema.not = { enum: description.notOneOf }; } if (description.label) { jsonSchema.title = description.label; } if (description.default !== undefined) { // @ts-expect-error default is unknown jsonSchema.default = description.default; } return jsonSchema; }; export default commonConverter;