(add-field-specs schema)
(add-field-specs schema options)
Walk schema structure, building field specs with entry and exit transforms. Does not meaningfully transform schema except in wrapping the values of optional keys in :maybe
Control flow:
options
before calling
m/-walk on children, including render flag if schema is of a collection,
and setting required if at root, or schema is a map and optional=false.Walk schema structure, building field specs with entry and exit transforms. Does not meaningfully transform schema except in wrapping the values of optional keys in :maybe Control flow: - on enter: 1. check if schema is flagged as deferring to a child. If so, walk the child TODO: change this behvavior 2. check if the schema is a ref schema that should be derefed. If so, call m/-walk on the result of derefing it - this preserves path. 3. otherwise, use type of schema to add context to `options` before calling m/-walk on children, including render flag if schema is of a collection, and setting required if at root, or schema is a map and optional=false. 4. if context is marked as render, and schema is a collection, pass flag on. if schema is not a collection, unset flag for walking children (but somehow preserve flag for exit?) - on exit: - if schema
Transformer that adds placeholder values by schema type
Transformer that adds placeholder values by schema type
(collect-field-specs schema)
(collect-field-specs schema source)
(collect-field-specs schema source options)
(collect-field-specs schema
source
errors
{:malli-forms/keys [add-placeholder-inputs
placeholder-target selected-leaves]
:as options})
Given a schema, a value, optional errors, and options, encode the value according to the schema, then value the transformed value, turning it into a ::field-spec AST
Given a schema, a value, optional errors, and options, encode the value according to the schema, then value the transformed value, turning it into a ::field-spec AST
(complete-field-spec schema naive-field-spec child-specs)
Complete or override a field spec for a particular schema. Basic field spec
as produced by [[extract-field-spec]] will be provided, as well as specs
already generated for children. Keyed on schema type.
Default action is to return the naive spec; only necessary to override when
child specs inform parent spec in some way, such as with or
, and
, etc.
Complete or override a field spec for a particular schema. Basic field spec as produced by [[extract-field-spec]] will be provided, as well as specs already generated for children. Keyed on schema type. Default action is to return the naive spec; only necessary to override when child specs inform parent spec in some way, such as with `or`, `and`, etc.
Transformer that ensures that required and optional keys are present in maps by adding nil values when missing.
Transformer that ensures that required and optional keys are present in maps by adding nil values when missing.
The keys of a field spec, as they will appear when embedded in the properties of a schema
The keys of a field spec, as they will appear when embedded in the properties of a schema
Namespace of keys that control behavior on field generation for schemas
Namespace of keys that control behavior on field generation for schemas
(handle-submit schema raw-data)
(handle-submit schema raw-data options)
Provide original schema and data as returned by ring-nested-params directly;
that is, a map containing the desired value to match against schema
under
base-data-key.
Updates options based on form data, unless ::ignore-form-options is set.
Returns a map containing :value, the desired parsed value, :schema, the
provided schema, and :form, a delay that, when realized, re-renders the form
with the new value and any parse errors encountered. In the scenario that
parse errors are encountered, they will be included under :errors.
Provide original schema and data as returned by ring-nested-params directly; that is, a map containing the desired value to match against `schema` under base-data-key. Updates options based on form data, unless ::ignore-form-options is set. Returns a map containing :value, the desired parsed value, :schema, the provided schema, and :form, a delay that, when realized, re-renders the form with the new value and any parse errors encountered. In the scenario that parse errors are encountered, they will be included under :errors.
(parse schema data)
(parse schema data {:malli-forms/keys [validate] :as options})
Simple parse using schema against data. Throws on failure. data should be as returned by ring's nested-params middleware, but should NOT be wrapped in the containing map - that is, the data should match the schema.
Simple parse using schema against data. Throws on failure. data should be as returned by ring's nested-params middleware, but should NOT be wrapped in the containing map - that is, the data should match the schema.
(parse-failed? x)
Is x an instance of ParseFailure
Is x an instance of ParseFailure
Transformer stack for parsing input data
Transformer stack for parsing input data
Schema types that are subject to m/parse and m/unparse
Schema types that are subject to m/parse and m/unparse
Transformer that removes keys with nil values from maps when those values are optional.
Transformer that removes keys with nil values from maps when those values are optional.
(render-form schema)
(render-form schema source)
(render-form schema source options)
(render-form schema source errors options)
Renders a form based on a schema. Accepts various optional arguments:
Rendering a form consists of the following steps:
Renders a form based on a schema. Accepts various optional arguments: - source: initial data to seed form with. default: nil - options: malli options map. see options-schema for custom keys. default: {} - errors: seq of errors produced by m/explain Rendering a form consists of the following steps: 1. Provided schema is wrapped in a map, under the key base-data-key. This allows for consistent handling of schemas that aren't maps, as well as allowing for storing other data in the form, such as an anti-forgery token, or signals to this library to help with adding placeholder values. 2. Wrapped schema is run through add-field-specs, which walks the entire schema, adding path information and calculating various attributes, such as whether or not the given item should render as a field, input type, etc., based on the schema and sometimes its children. 3. Source data is wrapped in a map under base-data-key (TODO TODO), and transformed according to the prepared schema, ensuring that required map keys are present, adding default values, and adding placeholders based on the provided options; i.e., either in all possible cases, or to a particular field. 4. The transformed data is walked, using the path to each location in the data to locate a relevant field spec, adding any errors, and outputting nil, the field spec, or a collection field spec with the original value under the key :children; at this point, the output is an AST of the type defined in the local registry as ::field-spec. 5. The AST is transformed by calling the function under ::render in the options (default: malli-forms.render.table/render) with each node. A good option for this function is a multimethod dispatching on :type; it should return something representing the HTML-encoded form, be it hiccup, or a String directly; depends on what your rendering pipeline looks like.
(render-specs source)
(render-specs source options)
Given a value as produced by collect-field-specs and options, renders fields defined by AST into markup
Given a value as produced by collect-field-specs and options, renders fields defined by AST into markup
(schema-index schema)
Provide a schema; receive a function that, when called with a value path (as in util/pathwalk), returns the subschema associated with that path
Provide a schema; receive a function that, when called with a value path (as in util/pathwalk), returns the subschema associated with that path
Simple mapping from schema type to HTML form input type
Simple mapping from schema type to HTML form input type
Map of input type keywords to the schema types that they correspond with
Map of input type keywords to the schema types that they correspond with
Transformer that handles the way data in sequential forms (including sets) will be returned by ring's nested-params middleware, namely:
x[0][a]=1&x[0][b]=2
;=>
{:x {:0 {:a "1", :b "2"}}}
In a nutshell: when this transformer encounters a map where a flat collection is expected, it returns the values of the map. Further coercion should be performed by other transformers, like malli.transformer/collection-transformer
Transformer that handles the way data in sequential forms (including sets) will be returned by ring's nested-params middleware, namely: ``` x[0][a]=1&x[0][b]=2 ;=> {:x {:0 {:a "1", :b "2"}}} ``` In a nutshell: when this transformer encounters a map where a flat collection is expected, it returns the values of the map. Further coercion should be performed by other transformers, like malli.transformer/collection-transformer
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close