Skip to content

Support serialized fields transforming #245

@kettanaito

Description

@kettanaito

What

Add support to pre-format the serialized value of a field.

Why

This feature can be used in multiple scenarios:

  1. Encrypt the entered password upon serialization (before sending/accessing the data).
  2. Format date input value to match the desired date format.
  3. General value normalization (casing, characters stripping)

How

  • As a part of createField options (not preferable)
  • Would be nice to have it as serialize method on the instance of a custom component wrapped in createField

Specification

General statements

  1. Serialization formatting affects only the returned serialized value. It has no affect over the actual field's value, or field's state, in general.
  2. It is possible to provide a custom serialization formatter in two ways:
    1. Upon the field's composition.
    2. As a dedicated prop to the field's instance.
  3. When no custom formatter function is provided, a field's value is returned during the serialization (as it is now)

Syntax

type SerializeFunc<ValueType> = (value: ValueType) => ValueType

Metadata

Metadata

Assignees

Labels

enhancementEnhances existing functionality.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions