Skip to content

Value of Field in Store Depends on Field Display #55

Open
@StevenXL

Description

@StevenXL

What are you reporting?

  • Bug
  • Feature request
  • Code refactor
  • Continuous Integration (CI) improvement
  • Changes in documentation (docs)
  • Other (describe)

What is the current behavior?

I have the following code:

import { createTextMask } from "redux-form-input-masks";

const ssnMask = createTextMask({
  pattern: "xxx-xx-999",
  maskDefinitions: {
    9: { regExp: /[0-9]/ },
    x: { regExp: /\d/, transform: () => "*" }
  }
});

What I am trying to express is the following: Allow only 9 numbers. Store that in the form's state. When you display it to the user, the first 6 numbers should be asteriks, the rest should not be transformed.

Am I unable to express the idea above in this library? I understand now that the transform property is expressing how to transform the input for storage, not how to transform it for display. However, the documentation reads Also, the value of the Fields in any application should be agnostic of how the Fields themselves are presented to the user.; so it seems from the documentation what I want should be possible. Maybe I am missing a feature that this library provides, but I can't figure it out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttext maskRefers to the `createTextMask`

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions