API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  To perform the json field level validation

    Posted Fri August 23, 2024 05:56 AM

    Hi Team,

    We need to perform json field level validation. We have 3 field(Customer Id, name, loan amount). If we pass any special character in the given filed then need to print appropriate error message so please guide us how we can do this on the IBM API Connect



    ------------------------------
    Jyoti Pednekar
    ------------------------------


  • 2.  RE: To perform the json field level validation

    Posted Fri August 30, 2024 10:52 AM

    Hi Jyoti,
    Please clarify by what you mean by "special characters".  You could have a schema in your API definitions that could be used by a validate policy, and the schema does have a number of validation properties, including a pattern property where you would specify a regular expression, so if the name field has anything but alphabetic characters for example it would fail the validation policy. The only drawback is that the validate policy error messages you have no control over, so hopefully the error that is presented is "appropriate".

    Specifically to the schema in your API definition, the DataPower Gateway supports an older draft of the JSON schema validation specification which can be reviewed at https://json-schema.org/draft-04/draft-fge-json-schema-validation-00

    and in particular the pattern property https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.5.2.3 would be where you would specify this regular expression.  You could also specify minimum and maximum string lengths for example.

    Best Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------