UNPKG

@vue-use-form/yup

Version:

yup resolver for vue-use-form

25 lines (20 loc) 601 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const vueUseForm = require('vue-use-form'); async function parseYupSchema(schema, values, options) { const errors = {}; try { await schema.validate(values, options); } catch (errs) { errs.inner.forEach((err) => { vueUseForm.set(errors, err.path, err.message); }); } return errors; } function useYupResolver(schema, options = {}) { return async (values) => { return await parseYupSchema(schema, values, { abortEarly: false, ...options }); }; } exports.useYupResolver = useYupResolver;