Layer7 API Management

Expand all | Collapse all

JSON Schema Validation asserion can validate a field which can hold more than 2 types of data i.e Integer/String/Number

Jump to Best Answer
  • 1.  JSON Schema Validation asserion can validate a field which can hold more than 2 types of data i.e Integer/String/Number

    Posted 10-01-2018 04:26 AM

    I am trying to validate a field in payload which could hold either integer or string using the below code but it's not validated in 9.0.0.

    {"type": ["string","integer"]}

    I found on the below sites it can be done in draft#02

    https://tools.ietf.org/html/draft-zyp-json-schema-02#page-7

    But,when I am keeping the type as mentioned above in my code then it is accepting both the values at the same it doesn't throw error when I am passing other datatypes such as object ,array, boolean etc in the field.Can anyone help me for the same.Is it doable in draft 2 or not.However,in higher versions I found it is doable.

     



  • 2.  Re: JSON Schema Validation asserion can validate a field which can hold more than 2 types of data i.e Integer/String/Number
    Best Answer

    Posted 10-01-2018 07:19 AM

    Hi ,

     

    I am not sure if this works in GW 9.00 in 9,3 we at least support Json draft v4.

    There is also a user story out there to enhance this in a future version , did you check if this works in 9.3.

     

    Feel free to raise a support case so we can have a closer look at this .

     

    Regards Dirk



  • 3.  Re: JSON Schema Validation asserion can validate a field which can hold more than 2 types of data i.e Integer/String/Number

    Posted 10-08-2018 08:16 AM

    Hi

    Did the answers on this thread answered your question? If it did please mark it as the right answer.
    When your question is not answered or you still have additional questions please let us know.

    With Kind Regards
    Dirk