Facebook
From Sweet Lion, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 185
  1. //validate schema
  2. var jsonData = pm.response.json();
  3. var loginSchema = {
  4.     "$schema": "http://json-schema.org/draft-04/schema#",
  5.     "type": "object",
  6.     "required": [
  7.         "id", "token", "userName", "password", "token"
  8.     ],
  9.     "properties": {
  10.         "id": {"type": "number"},
  11.         "firstName": {"type": "string"},
  12.         "lastName": {"type": "string"},
  13.         "userName": {"type": "string"},
  14.         "password": {"type": ["string", "null"]},
  15.         "token": {"type": "string"}
  16.     }
  17. };
  18.  
  19. var validationResults = tv4.validateMultiple(jsonData, loginSchema);
  20. console.log(validationResults.errors);