Date field validation
Monday, April 12, 2021 at 09:21amHello,
In Java, I would like to add a new field where the signer should fill in a date (in a date format DD/MM/YYYY).
- What type of field should it be?
- The signer should be allowed to add either the current date or one from the past. Not a future date. Is there any way to validate it and show an error message in case the validation is not passed?
Thanks,
Michail
Reply to: Date field validation
Monday, April 12, 2021 at 09:54amHi Michail,
You can use either text field or date picker field. But with both types, there's temporary no way to limit the input value to be a past or current date. We can definitely raise it as an Enhancement Request but it's not available yet.
If you choose to use date picker field, use below SDK code or API JSON:
Java SDK:
Field datepickerField = FieldBuilder.datepicker()
.onPage(0)
.atPosition(100, 100)
.withSize(150, 50)
.withValidation(FieldValidatorBuilder.datepickerFormat("dd-MM-YYYY").withErrorMessage("Please select a current or past date!"))
.build();
REST API:
{
"validation": {
"required": true,
"errorMessage": "Please select a current or past date!",
"pattern": "dd-MM-YYYY"
},
"id": "gjmeqWErMVoG",
"page": 0,
"subtype": "DATEPICKER",
"left": 125,
"top": 83,
"width": 150,
"height": 50,
"type": "INPUT"
}
Duo
Reply to: Date field validation
Wednesday, April 14, 2021 at 05:51amHello Duo,
Thanks for your answer and your code examples.
Best Regards,
Michail
Reply to: Date field validation
Wednesday, April 14, 2021 at 09:08amHi Michail,
The field validator in both classic and new signer experience could only tell if the format is wrong (if the value is passed in through API), or if the field is empty. Field validator also supports regular expression, but since the current date is dynamic, it's not very likely to match the current date by a RegExr. And it's not possible to hijack the validation process and provide a confirmation popup.
I would suggest we fill in an Enhancement Request asking for a native validator type for future/past date.
Duo
Reply to: Date field validation
Wednesday, April 14, 2021 at 12:27pmHello Duo,
If we fill in an Enhancement Request, when do you think it will be available in Sandbox (US1) and Production (US1) environments?
Thanks and Regards,
Michail
Reply to: Date field validation
Wednesday, April 14, 2021 at 12:41pmHi Michail,
In order to fill in an Enhancement Request, please supply a brief description and your business motivation behind this suggestion. After we added your submission to our database of enhancement requests, product team would review and evaluate the suggestion based on a number of factors, including:
We will be in touch in 5-7 business days to let you know if your enhancement request is accepted or declined for roadmap consideration. However, we cannot guarantee that your request will be added to our roadmap and it's hard to tell the ETA until the feature has already been on the roadmap plan.
Duo
Reply to: Date field validation
Friday, April 30, 2021 at 05:09amHello Duo,
From which release is the datepicker available in the FieldBuilder?
I use the 10.9.1 sdk of OneSpan and when I try to use the FieldBuilder.datepicker() in Java, I get the following error:
The method datepicker() is undefined for the type FieldBuilder
Best Regards,
Michail
Reply to: Hello Duo, From which…
Friday, April 30, 2021 at 08:46amHi Michail,
I believe this field type is supported in SDK since version 11.0.1, see below Git history:
https://github.com/OneSpan/esl.sdk.java/commit/06ca7a86392469d4486df1db8e57aeb4595c617f#diff-0148ed8ca253049290a76a05d9f07ade0c23ab6c6e20aabc094b74ef599c7a78
Duo
Reply to: Date field validation
Monday, May 31, 2021 at 01:28amHello Duo,
Thanks for your answer. Unfortunately, we cannot simply use the new version of sdk, as it has to be checked and approved by our security team first. And it might take time.
Is it possible to build the datepicker locally somehow? By executing the code of sdk locally?
Thanks and Regards,
Michail
Reply to: Hello Duo, Thanks for…
Tuesday, June 1, 2021 at 09:06amHi Michail,
There's no need to modify the SDK source code and you can create a date picker field use below code instead:
FieldBuilder datepicker = FieldBuilder.newField()
.withStyle(FieldStyle.UNRECOGNIZED("DATEPICKER"))
.withValidation(FieldValidatorBuilder.regex("YYYY-MM-dd").withErrorMessage("Please select a current or past date!"))
.onPage(0)
.atPosition(200, 100)
.withSize(200, 55);
However, because date picker field is not part of the SDK 10.9.1 modelling, the field won't be returned in .getPackage() function.
Duo
Reply to: Date field validation
Tuesday, June 1, 2021 at 09:15amHello Duo,
Many thanks for the helpful answer.
Two clarifications please:
Best Regards,
Michail
Reply to: Hello Duo, Many thanks…
Tuesday, June 1, 2021 at 09:21am1. then use "dd-MM-YYYY" instead (I changed it for testing purpose)
2. if you loop through all fields, this date picker field won't be printed out:
DocumentPackage package1 = eslClient.getPackage(packageId);
for (Document document : package1.getDocuments()) {
for (Signature signature : document.getSignatures()) {
for (Field field : signature.getFields()) {
System.out.println(field.getId() + " " + field.getStyle().name());
}
}
}
At the lower level, this is caused because the SDK indicates its version in the request and therefore the API response didn't return the unsupported field types.
Duo
Reply to: Date field validation
Tuesday, June 1, 2021 at 10:34amHello Duo,
How can I set it to mandatory, at the same time?
Regards,
Michail
Reply to: Hello Duo, How can I set…
Tuesday, June 1, 2021 at 10:36amAdd the .required() to the chain of functions:
FieldBuilder datepicker = FieldBuilder.newField()
.withStyle(FieldStyle.UNRECOGNIZED("DATEPICKER"))
.withValidation(FieldValidatorBuilder.regex("dd-MM-YYYY").required().withErrorMessage("Please select a current or past date!"))
.onPage(0)
.atPosition(200, 100)
.withSize(200, 55);
Duo
Reply to: Date field validation
Tuesday, June 1, 2021 at 10:49amMany thanks Duo! It works!
As default message in the date picker box, is written (in French): Cliquer pour etablir
Is it possible to change this message to a different one, which I can define?
Best Regards,
Michail
Reply to: Many thanks Duo! It works! …
Tuesday, June 1, 2021 at 11:00amHi Michail,
Can't recollect if we've talked about this - it seems you are still using the classic Signing Ceremony which will soon be deprecated in release 11.42. All users will migrate to our New Signer Experience and the date picker field also renders differently.
Duo
Reply to: Hi Michail, Can't…
Tuesday, June 1, 2021 at 11:03amHello Duo,
Yes, I am aware of this change. Is there a different behavior of the date picker in the New Signer Experience?
Is it possible to change the "Cliquer pour etablir" in the Classic Signer Experience, via Java?
Regards,
Michail
Reply to: Date field validation
Tuesday, June 1, 2021 at 11:23amOne more question Duo:
I tried with the date format "dd/MM/YYYY" and I got the error
Optional details: {"messageKey":"error.validation.field.badDateFormat","message":"The field's value does not conform to the required date format.","code":400,"name":"Validation Error"}
Does it mean that the format "dd/MM/YYYY" is not supported and I have to use the format "dd-MM-YYYY" ?
Best Regards,
Michail
Reply to: Hello Duo, Yes, I am…
Tuesday, June 1, 2021 at 11:24amYes, it's possible to customize this UI label, but it can only be set up by support team([email protected]), with below resource name:
"esl.templates.package_form.click_to_set":"placeholder text"
Essentially there shouldn't have functional differences in new and classic signer experiences, it just provides a different look and feel. And for the UI label, new signer experience displays the format e.g. "YYYY-MM-DD" instead of different translations of "click to set".
Duo
Reply to: One more question Duo: I…
Tuesday, June 1, 2021 at 11:26amYes, date picker field only supports one of below formats:
YYYY-MM-DD
YYYY-DD-MM
MM-DD-YYYY
DD-MM-YYYY
Duo