App Connect

 View Only
  • 1.  Conditional Mandatory Field Validation in JSON Request Using ESQL/DFDL

    Posted 15 days ago

    Hi,

    I have a requirement to validate a JSON request with conditional mandatory fields. This means if a JSON request has 5 fields and the first field exists, then the second and third fields must also exist. How can we achieve this using ESQL without using if conditions? Is there any way to handle this in DFDL?

    Kindly suggest a solution to complete this. Thanks in advance.



    ------------------------------
    Manideep vusakoila
    ------------------------------


  • 2.  RE: Conditional Mandatory Field Validation in JSON Request Using ESQL/DFDL

    Posted 9 days ago

    Hi Manideep,

    You can achieve this using DFDL JSON schema. On the HTTP Input node, you need to configure 

    1. Message Domain: JSON
    2. Message Model: Your json schema
    3. Parser Options: Parser timing = Complete/Immediate
    4. Validation: Content and Value

    Below is the schema definition for your requirement:

    {
      "$schema": "http://json-schema.org/draft-04/schema#",
     "type": "object",
      "properties": {
      "name": { "type": "string" },
        "credit_card": { "type": "number" },
        "mobile": { "type": "number" }
      },
      "required": ["name"],
      "dependencies": {
        "credit_card": {
          "additionalProperties": {
          "allOf": [
                       {"address1": { "type": "string" }},
                       {"address2": { "type": "string" }},
                       {"expiry": { "type": "string" }}
                    ]
            
          },
          "required": ["address1","address2","expiry"]
        }
      }
    }

    Sample Test Message:

    {
        "name": "John Doe",
        "credit_card": 790054009987,
        "address1": "66666, Prescott St",
        "address2": "Massachusetts,94955",
        "expiry": "03/25",
        "mobile": 8230832040
    }

    Thanks

    Uvaise Ahmed



    ------------------------------
    uvaise odam
    ------------------------------



  • 3.  RE: Conditional Mandatory Field Validation in JSON Request Using ESQL/DFDL

    Posted 4 days ago

    Thanks @Uvaise Ahmed



    ------------------------------
    Manideep vusakoila
    ------------------------------