CustomErrorMessage and removeMaskDocument props #252
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What did you change? *
Added two new properties that receive values from the store-theme, similar to the blockDocument prop
The first is the customErrorMessage property, which is used to change the default generic message in the handleSubmit in profileFormBox and receives a string
The second is the removeMaskDocument property, which is used to remove the mask from the document field before sending it to the customer table, it receives a boolean value
Validations were also added for these properties, making them optional and not interfering with the default behavior that stores currently use
Why? *
We needed a way to prevent users from entering a duplicate document (which is already registered in another account)
To reach this goal, we went through several problems. The first was a known issue "Unable to filter by text field", where it is suggested to change the document field to a Varchar 750, but to do that we would need to delete our field and create a new one, losing all our data.
We tried an alternative way through safeData, we were not successful either.
The only method that worked almost perfectly was to create an alternate key for the document field. \0/
Unfortunately the message that currently appears is very generic and it is not clear to the user which field the problem is in, so we made the customErrorMessage prop.
We added the removeMaskDocument prop because letting the mask mess up our MasterData, and this is a failure that cannot pass, since we use the document as an alternate key and there could be scenarios with documents like this: "999.999.999-99" and "99999999999"
How to test it? *
Testing removeMaskDocument prop
Testing customErrorMessage
Related to / Depends on?
depend on:
the custom Error Message prop was used here: vtex-apps/my-account-commons#60
does not depend, but is related... I would be grateful if you could review:
vtex/profile-form#143
Types of changes *