UNPKG

@tuentyfaiv/svelte-form

Version:

A form library for Svelte. It is built on top of Svelte and Typescript. Inspired by Formik and React Hook Form.

55 lines (54 loc) 1.43 kB
export class FormError extends Error { title; reason; message; date; constructor({ title = "!Form Error¡", message, reason, }, ...params) { super(...params); if (Error.captureStackTrace) { Error.captureStackTrace(this, FormError); } this.name = "FormError"; this.title = title; this.message = message; this.reason = reason; this.date = new Date(); } } export class SchemaError extends Error { title; field; reason; schema; value; date; constructor(config, ...params) { super(...params); if (Error.captureStackTrace) { Error.captureStackTrace(this, SchemaError); } this.name = "SchemaError"; this.title = "!Field error¡"; this.field = config.field; this.reason = config.reason; this.schema = config.schema; this.value = config.value; this.message = config.message; this.date = new Date(); } } export class SchemaErrorList extends Error { title; errors; date; constructor(errors, ...params) { super(...params); if (Error.captureStackTrace) { Error.captureStackTrace(this, SchemaErrorList); } this.name = "SchemaErrorList"; this.title = "!Fields error¡"; this.errors = errors; this.date = new Date(); } }