Validation

Overview

PruTAN Validation enables automated tests for ISO responses after execution. Write JavaScript using the pv API to validate status codes, fields, and content.

  • Add multiple validations per request
  • Works for saved/unsaved requests and collections

Key Features

  • Post-response execution
  • pv.test() groups assertions
  • Results in Test Results tab

Writing post-request validation

PruTAN ships a powerful API called pv which can handle post-request validation. Here we'll use pv to run validation on the response received from APIs.

Common Validation Examples

Let us look at some examples of how you can use PruTAN to write validation.

Test response status code and Field id = 3 value

The following examples show how to validate the response status code and confirm that ISO fields contains the expected value.

  • Uses UPI Transaction request example

There are two ways to test the status code:

ConditionCode
Check if response code is 200pv.test("Status code is 200", res.validateResponse("200"))
// Status 200 & ISO fields (UPI example)
pv.test("UPI Response OK", 
  res.validateResponse("200"),
  res.isValuePresent("3", "310000"),  // Processing Code
  res.isValuePresent("0", "0210"),    // Response MTI
  res.isValuePresent("39", "00"),     // Approval
  res.isFieldNotPresent("18")         // No PAN in response
);

Notes

  • To know more about validation scripts please checkout our sample scripts provided by PruTAN in right side of the Validation Tab.
  • Validation results are displayed in the Test Results tab of the Response section.