diff --git a/src/index.ts b/src/index.ts index 6f6109c..022d7fa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import { isSchema, ValidationError } from 'yup'; import { clone } from './utils'; import type { Readable, Unsubscriber, Writable } from 'svelte/store'; -import type { Schema } from 'yup'; +import type { Schema, ValidateOptions } from 'yup'; export { field } from './action'; @@ -249,6 +249,12 @@ export type FormConfig = { * [1]: https://github.com/jquense/yup */ validationSchema?: Schema; + /** + * [Yup][1] validation options used internally + * + * [1]: https://github.com/jquense/yup + */ + validationOptions?: ValidateOptions; }; /** @@ -516,9 +522,12 @@ export const newForm: NewFormFn = ( try { __isValidating.set(true); - await config.validationSchema.validate(currentValues, { - abortEarly: false, - }); + await config.validationSchema.validate( + currentValues, + config.validationOptions + ? config.validationOptions + : { abortEarly: false }, + ); } catch (error) { console.warn(error); if (error?.inner) {