New Signer Experience: Two validation errors instead of one
Tuesday, April 6, 2021 at 09:59amCode:
.withValidation(FieldValidatorBuilder.regex("^\\d{2}/\\d{4}$").required().withErrorMessage("Please enter a valid retirement date (MM/YYYY)"))
When we are testing and when we do not enter a value, we are seeing what looks like an overriding validation error message than the one we configure in the code. See attached. When we enter a value that does not adhere to regex, we see correct validation error.
We would like the error we configure in the code to be the one we see whether there is a value entered or not.
Please advise.
Reply to: New Signer Experience: Two validation errors instead of one
Tuesday, April 6, 2021 at 10:33amHi Esteban,
I believe we have reported this before, however, it was not fixed in the exact same way as the classic signing ceremony - that the error types and their error messages are still categorized and prioritized in below order:
If required > If less than minimal length (front end prevents signer to insert more than maximum length) > If pattern is respected
So in your case, you will see your customized error message as long as you entered anything to the field.
Duo
Reply to: New Signer Experience: Two validation errors instead of one
Tuesday, April 6, 2021 at 10:38amSo, just so I understand correctly: A user will get a "required" error message ahead of the regex error message if there is no value in the field. And there is no way to override the required error message. Is that correct?
Reply to: So, just so I understand…
Tuesday, April 6, 2021 at 10:42amYes, and since the required error message is general for all fields, you can only customize the default wording at the account level, not field level.
Duo
Reply to: New Signer Experience: Two validation errors instead of one
Tuesday, April 6, 2021 at 10:43amCan I do this?
.withValidation(FieldValidatorBuilder.basic().required().withErrorMessage("Please enter a valid retirement date (MM/YYYY)"))
.withValidation(FieldValidatorBuilder.regex("^\\d{2}/\\d{4}$").withErrorMessage("Please enter a valid retirement date (MM/YYYY)"))
Reply to: Can I do this? …
Tuesday, April 6, 2021 at 10:47amHi Esteban,
This seems working for me! Let me test further and reply back to you!
Duo
Reply to: New Signer Experience: Two validation errors instead of one
Tuesday, April 6, 2021 at 10:48amOkay, thank you.
Reply to: Hi Esteban, This seems…
Tuesday, April 6, 2021 at 10:53amI see. Let me put it in another way - if you already have the Regular expression like below, which implies the input can't be empty, should be exactly 2 numbers follows by slash follows by 4 numbers (7 chars), you no longer need to explicitly specify .required() or .minLength()/.maxLength()
.withValidation(FieldValidatorBuilder.regex("^\\d{2}/\\d{4}$").withErrorMessage("Please enter a valid retirement date (MM/YYYY)"))
In which case, only the customized error message will be displayed.
Duo
Reply to: New Signer Experience: Two validation errors instead of one
Tuesday, April 6, 2021 at 10:56amOk, so all I need to do is take out the "required()" and it will work as expected?
Reply to: Ok, so all I need to do is…
Tuesday, April 6, 2021 at 10:57amExactly!
Duo