svelte-form

Svelte Form module.

Source:

(require("svelte-form"))(fields, validation, opts) → {module:svelte-form~Form}

Source:

Create a new form store

Parameters:
Name Type Description
fields object

Form fields.

validation object

Validation rules mapping. Where each key is a fn(val)->boolean validation function or an array of fn(val)->boolean validation functions.

opts object

Form options.

Properties
Name Type Description
onCreateValidation boolean

Validate form fields when the form is created. Defaults to false.

Returns:
Type
module:svelte-form~Form

Type Definitions

Form

Source:
Properties:
Name Type Description
subscribe function

Svelte store, context {valid: boolean}.

field function

Get form field observable value and state. Signature fn(key), returns {module:svelte-form~FormField}.

validate function

Trigger all fields validation.

data function

Get all form fields data. Signature fn().

Form object

FormField

Source:
Properties:
Name Type Description
value function

Writeable Svelte store, context: mixed value.

state function

Readonly Svelte store, context: {valid: boolean, error: string}.

FormField object