Enhancer: Field mask
See original GitHub issueWhat
Need to introduce field format.
Why
It’s quite comfortable to have the value entered formatted in the pre-defined way.
How
Field format/template will enforce the provided value to be in the provided format/template. Formatting works onChange and on paste.
Example
Imagine there’s a cardNumber
field for entering your credit card’s number. It’s great to have the value be 4 digits separated with spaces while the user types.
<Field.Input
name="cardNumber"
format="#### #### #### ####"
required />
This will enforce the given format while user types.
Specification
- Field should behave as templated whenever it has a
format
prop. - Field formatting happens onChange and onBlur to ensure it’s strictly followed.
- The core functionality for field formatting is a pure function (
formatField({ fieldProps })
for example). It should have nothing to do with the form, its context, or whatsoever. Takes props and ensures that thevalue
is in the properformat
. - A char
#
is used as a placeholder for an actual entered value. Therefore, an expected format of format (lol) is###-###-###
, for example.#
are then substituted by the actual field value. - Format should be ensure when the field mounts (registers in the form). This way initial values are formatted as well.
- (Optional) Maybe we should think of situations when the end developer will not supply the whole format, but its beginning only?
Test scenarios
- Credit card number:
#### #### #### ####
- Phone number:
+(###) ### ### ###
- Birth date:
##/##/####
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
Con-CUSHION Mask Enhancer | Gerry Davis Sports
Introducing the Con-CUSHION Mask Enhancer - a new product designed to be attached to your umpire or catcher's mask to reduce the risk...
Read more >Impact of mask enhancer on 65-nm node contacts - IEEE Xplore
Introduction. Fabricating contacts for sub-65-nm node LSk with an ArF exposure tool is a major challenge in optical lithography because it is very...
Read more >formik-enhancer - npm
Formik generator. Latest version: 1.0.8, last published: 3 years ago. Start using formik-enhancer in your project by running `npm i ...
Read more >Do I Still Need The Color Enhancer? Yes, In This One Situation
The value add of the Color Enhancer is that it is an Effects filter and you have the masking tools. Target the purity...
Read more >Mask Enhancer Technology with Source Mask Optimization (SMO ...
Request PDF | Mask Enhancer Technology with Source Mask Optimization (SMO) for 2Xnm-node Logic Layout Gate Fabrication | Strong resolution enhancement ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We can use custom “mask” string. Consider: passing
XXX{-}XXX{-}XX
will add dashes like this:082-233-22
Hello, @aazcast.
No, this feature has been agreed to be too specific for a form to handle. We were working on introduction of granular field lifecycle methods in
createField
API. The API is released and stable, so you should use it instead.It should be possible to implement a value masking as follows (pseudo code):
Let me know if this answers your question.