antoniopresto / antd-mask-input

MIT License
88 stars 38 forks source link

dynamic mask pattern and maxLength problem #36

Closed shinrox closed 2 years ago

shinrox commented 2 years ago

Currently, the behavior of adding a maxLength prop to the field based on the mask length, breaks the possibility of having dynamic masks in the same input

Especially for Brazilian forms, we have some fields in which the length and mask might vary, and it makes it impossible to do something close to this, or like masking a common document input type that we use, which the length vary from 11 to 18 chars and the masks are completely different (999.999.99-99 and 99.999.999/9999-99)

I think this is not the same as an optional character, but a completely different expected value and mask in the same field

We thought about the approach of using a select option so the user define the type of the document and we go from there, but this is actually a not expected behavior from a mask, so I'm calling it a bug, feel free to change it if you like ;)

antoniopresto commented 2 years ago

I just published version 2.0 See examples in tests, readme or storybook: https://github.com/antoniopresto/antd-mask-input/blob/master/stories/input.stories.tsx

renerlemes commented 1 year ago

@shinrox Were you able to use the mask for CPF and CNPJ? I've been having this problem for days and I can't do it at all?