Validate JSON Schema date-time format Failure: $.incorpDt: does not match the date-time pattern
search cancel

Validate JSON Schema date-time format Failure: $.incorpDt: does not match the date-time pattern

book

Article ID: 231429

calendar_today

Updated On: 04-28-2025

Products

CA API Gateway

Issue/Introduction

During our testing we observed that  date-time type is not  being validated properly and getting failed.

      "incorpDt": "2021-02-19 00:00:00",

 {

"code": "400",

"subcode": "400",

"message": "Bad Request",

"details": "Request Schema Validation Failed. $.request.party.incorpDt: does not match the date pattern ^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}$ "

}

 

Sample Req:

{

  "parameters": {

    "lobId": "CBD",

    "callingSystem": "DAO",

    "callingSystemIdentifier": "fd9c1649-079b-4855-b632-e7de4f7a0e9f",

    "riskScore": true,

    "adverseNews": false,

    "sanctions": true,

    "screenAndScoreOnly": true,

    "pep": true

  },

  "request": {

    "party": {

      "key": {

        "id": "62221307"

      },

      "partyType": "O",

      "fullName": "<NAME>",

      "custLifecycleStatus": "OPEN",

      "legalName": "<NAME>",

      "addresses": [

        {

          "addrType": "HOME",

          "addrLine1": "<Address>",

          "addrLine2": "",

          "addrLine3": null,

          "city": "<CITY>",

          "stateProv": "<STATE>",

          "countryCode": "<COUNTRY>",

          "postalCode": "<ZIP>"

        },

        {

          "addrType": "MAIL",

          "addrLine1": "<ADDRESS> ",

          "addrLine2": "",

          "addrLine3": null,

          "city": "<CITY>",

          "stateProv": "<STATE>",

          "countryCode": "<COUNTRY>",

          "postalCode": "<ZIP>"

        }

      ],

      "legalType": "SOLE_PROPRIETORSHIP",

      "incorpDt": "2021-02-19 00:00:00",

      "taxId": "<TAXID>",

      "taxIdType": "EIN"

    },

    "properties": []

  }

}

 

JSON Schema validation failure. $.payload.items[0].recertifications[0].events[0].date: does not match the date-time pattern ^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}[tT ]\d{2}:\d{2}:\d{2}(\.\d+)?([zZ]|[+-]\d{2}:\d{2})$: Attempted to validate with JSON Schema Draft V4

 

"date":"2021-08-19 14:08:33.278341"

{

    "title": "Recertification - Search",

    "type": "object",

    "definitions": {},

    "$schema": "http://json-schema.org/draft-04/schema#",

    "properties":

    {

       "payload":

       {

          "type": "object",

          "properties":

          {

             "items":

             {

                "type": "array",

                "uniqueItems": true,

                "items":

                {

                   "type": "object",

                  "properties":

                  {

                      "party":

                      {

                         "type": "object",

                         "properties":

                         {

                            "id":

                            {

                               "type": "string",

                               "title": "Party ID (MDM)",

                               "maxLength": 14

                            },

                            "lob":

                            {

                               "type": "string",

                               "title": "Line of Business Name/ID (MDM)"

                            }

                         },

                         "required": [

                            "id",

                            "lob"

                         ]

                      },

                      "recertifications":

                      {

                         "type": "array",

                         "uniqueItems": true,

                         "items":

                         {

                            "type": "object",

                            "properties":

                            {

                               "id":

                               {

                                  "type": "string",

                                  "title": "Recertification Id"

                               },

                               "type":

                               {

                                  "type": "string",

                                  "title": "Recertification Type",

                                  "enum": [

                                     "FULL", "PARTIAL"

                                  ]

                               },

                              "due":

                               {

                                  "type": "string",

                                  "format": "date",

                                  "title": "Recertification Due Date"

                               },

                               "status":

                               {

                                  "type": "string",

                                  "title": "Recertification Status",

                                  "enum": [

                                     "NEW", "STARTED", "COMPLETED", "CANCELLED"

                                  ]

                               },

                               "events":

                               {

                                  "type": "array",

                                  "uniqueItems": true,

                                  "items":

                                  {

                                     "type": "object",

                                     "properties":

                                     {

                                        "id":

                                        {

                                           "type": "string",

                                           "title": "Compliance Event Id"

                                        },

                                        "date":

                                        {

                                           "type": "string",

                                           "title": "Compliance Event Timestamp",

                                           "format": "date-time"

                                        },

                                        "family":

                                        {

                                           "type": "string",

                                           "title": "Compliance Event Family Code",

                                           "readOnly": true,

                                           "enum": [

                                              "TRIGGERED", "SCHEDULED"

                                           ]

                                        },

                                        "code":

                                        {

                                           "type": "string",

                                           "title": "Compliance Event Code",

                                           "enum": [

                                              "HR"

                                           ]

                                        },

                                        "description":

                                        {

                                           "type": "string",

                                           "title": "Event description"

                                        }                                                                                                                                          

                                     },

                                     "required": [

                                        "id",

                                        "date",

                                        "family",

                                        "code"

                                     ]

                                  }

                               }

                            },

                            "required": [

                               "id",

                               "type",

                               "due",

                               "status",

                               "events"

                            ]

                         }

                      }

                   },

                   "required": [

                      "party",

                      "recertifications"

                   ]

                }

             }

          },

          "required": [

             "items"

          ]

       }

    },

    "required": [

       "payload"

    ]

}

 

Failure: $.incorpDt: does not match the date-time pattern ^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}[tT ]\d{2}:\d{2}:\d{2}(\.\d+)?([zZ]|[+-]\d{2}:\d{2})$

Environment

Release : 10.x, 11.x

Component : CA API Gateway

Cause

data type format incorrect

Resolution

Use the following format : datetime instead of date-time 

2. JSON Schema Validation Properties contains the following code :

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "description": "Test",
    "properties": {
        "taxId": {
            "type": "string",
            "description": "Tax ID",
            "required": true
        },
        "incorpDt": {
            "type": "string",
            "format": "datetime",
            "required": true
        }
    }
}

 

Additional Information

https://json-schema.org/understanding-json-schema/reference/string.html