File validation - Signature sessions
You can validate the files chosen by the user during signature sessions using the mechanisms described in this article.
File naming rule
If you have a naming rule for the files you accept, you can configure your Rest PKI Core account to validate each file selected by the user with a regular expression that represents your rule.
Consider a hypothetical situation in which only files whose name starts with the letter P or X, followed by 6 digits and the .pdf
extension, are accepted. To enforce this condition, the naming rule would be configured as:
^[PX]\d{6}\.pdf$
The user would then be prevented from choosing files whose names do not match this pattern:

Our developer support can help you write the regular expression from a textual description of your naming rule.
File validation API
You can also configure a file validation API, implemented by your application, to be called to validate each file chosen by the user. Your application receives the file name (along with its MIME type and size in bytes) and returns whether the file should be accepted (and, if not, the reason for the rejection).
The validation request is an HTTP POST request whose payload is a ValidateFileRequest object (see the
API reference for the model definition). For example:
{
"name": "P123456.pdf",
"contentType": "application/pdf",
"length": 2476032
}
Your application must respond with a ValidateFileResponse, as below:
{
"accept": true,
"rejectReason": null
}
Or, if the file is rejected:
{
"accept": false,
"rejectReason": "Message to the user"
}
The message returned by your application is shown to the user, for example:
