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!

27 lines (26 loc) • 798 B
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ function addMethod(yup, name) { yup.addMethod(yup.Schema, name, function (value) { const meta = this.describe().meta || {}; return this.meta({ ...meta, jsonSchema: { ...meta.jsonSchema, [name]: value } }); }); } export function extendSchema(yup) { addMethod(yup, 'example'); addMethod(yup, 'examples'); addMethod(yup, 'description'); yup.addMethod(yup.Schema, 'jsonSchema', function (callback) { const meta = this.describe().meta || {}; return this.meta({ ...meta, jsonSchema: callback(meta.jsonSchema || {}) }); }); }