It contains all logic functions for forms.
It contains all logic functions for forms.
(add-form-errors db form-id errors)
Adds a given errors
into the db
by a given form-id
.
The errors
should be a map with vectors
Adds a given `errors` into the `db` by a given `form-id`. The `errors` should be a map with vectors
(assoc-field-value db form-id field-id value)
Assocs a given value
into the db
by a given form-id
and field-id
Assocs a given `value` into the `db` by a given `form-id` and `field-id`
(assoc-values db form-id values)
Assocs a given values
into the db
by a given form-id
Assocs a given `values` into the `db` by a given `form-id`
(create-form form-map init-values)
Creates a Form
from a given map
.
Creates a `Form` from a given `map`.
(db->form db id)
Return a Form
by a given id
in the db
.
Return a `Form` by a given `id` in the `db`.
(field-state form id)
Returns a field's state as a string
.
Returns a field's state as a `string`.
(form->values form)
Returns form
's values as a hashmap.
Returns `form`'s values as a hashmap.
(form-errors<response db form-id errors)
Takes a response's body as errors and assoc them in the db
by a form-id
.
The errors
should be a map with vectors
Takes a response's body as errors and assoc them in the `db` by a `form-id`. The `errors` should be a map with vectors
(init-field id)
(init-field id value)
Initializes a Field
by id
, or value
with default values.
Initializes a `Field` by `id`, or `value` with default values.
(init-form db form-map initial-values)
Initializes a form in the db
within form-map
and initial-values
Initializes a form in the `db` within `form-map` and `initial-values`
(init-form! form-id validator)
(init-form! form-id validator initial-values)
Initializes a form in DB by a given form-id
with a validator
function that takes a map of fields values
and returns a map of vectors as errors or nil
. Optionally takes an initial-values
map.
Initializes a form in DB by a given `form-id` with a `validator` function that takes a map of fields values and returns a map of vectors as errors or `nil`. Optionally takes an `initial-values` map.
(input-on-blur! form id event)
Dispatches a input's on-blur event
Dispatches a input's on-blur event
(input-on-change! form id event)
(input-on-change! form id formatter event)
Dispatches a input's on-change event. Optionally takes a formatter
function that takes a new values and returns
formatter value.
Dispatches a input's on-change event. Optionally takes a `formatter` function that takes a new values and returns formatter value.
(validate-form form)
Validates a given form
by its valdiator. It returns new form with updated values:
errors
valid?
valid?
is updated tooValidates a given `form` by its valdiator. It returns new form with updated values: - `errors` - `valid?` - every field's `valid?` is updated too
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close