Svelte Form module.
(require("svelte-form"))(fields, validation, opts) → {module:svelte-form~Form}
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
|
Returns:
Type Definitions
Form
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
Properties:
Name | Type | Description |
---|---|---|
value |
function | Writeable Svelte store, context: mixed value. |
state |
function | Readonly Svelte store, context: {valid: boolean, error: string}. |
FormField object