gberde | Posts: 19

OneSpan Sign template - field validation

0 votes

Is there a way to apply validation rules on field values during signing ceremony? We have bunch of phone number fields and email address fields. We want to make sure that signers enter these fields in a specific format.  


Approved Answer
Duo_Liang | Posts: 3776

Reply to: OneSpan Sign template - field validation

0 votes

Hi gberde,

 

Yes, you can add field validations and restrict field values during the signing ceremony. Note that you can't add Regular expressions via UI and consider you are using templates, try to update template fields with this API combination:

Step0: As a general backup method, you can make a copy of you template in this way: in your sender UI > "Templates" > "New Template" > for the "Use Template" option, choose the existing template from the dropdown list, give the newly created template a different name (template name is unique) then create

Step1:

GET /api/packages/{template_id}/documents/{document_id}/approvals/{approval_id}

This retrieves all the fields under an approval. From the response JSON, find your target fields by id/name and add a "validation" node to them. Below example gives you an idea of how to build the validation JSON: 

{
  "role": "client",
  "fields": [
    {
      "validation": {
        "required": true,
        "errorMessage": "Please enter a valid phone number (XXX-XXX-XXXX)",
        "pattern": "^[2-9]\\d{2}-\\d{3}-\\d{4}$"
      },
      "subtype": "TEXTFIELD",
      "extract": true,
      "type": "INPUT",
      "name": "phone_number"
    },
    {
      "validation": {
        "required": true,
        "errorMessage": "Please enter a valid email.",
        "pattern": "^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$"
      },
      "subtype": "TEXTFIELD",
      "extract": true,
      "type": "INPUT",
      "name": "email"
    },
    {
      "subtype": "CAPTURE",
      "extract": true,
      "type": "SIGNATURE",
      "name": "client_signature"
    }
  ],
  "name": ""
}

Step2:

With the updated payload by hand, you can update the fields under the signature by a PUT call:

PUT /api/packages/{template_id}/documents/{document_id}/approvals/{approval_id}

 

Duo


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off