Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Add parsers and formatters #368

@kentcdodds

Description

@kentcdodds

Feedback appreciated: It would be really handy to be able to specify parsers and formatters (to support use cases like this. Something like this:

vm.fields = [
  {
    type: 'input',
    parsers: [appendCurly],
    formatters: [hissToSnake]
  }
];

function appendCurly(value) {
  return value + '}';
}

function hissToSnake(value) {
  return value === 'hiss' ? 'snake!' : value;
}

Some cases to consider:

  1. When merging the fields with defaultOptions we need to decide what order to apply the parsers and formatters (considering the order they are run in...)
  2. Should we provide a mechanism to override parsers or formatters? We could allow you to specify a property on the function that identified the parser/validator (like id) and that would be used to override them.
  3. Anything else I'm missing?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions