Layer7 API Management

  • 1.  Query Parameter format or pattern validation.

    Posted Jan 06, 2017 11:16 PM

    May I know which assertions should we use to validate  format or pattern of query parameter.

     

    Example:

    email pattern validation.

          -  {a-z} characters should be allowed

          -  {0-9} integers

          - only one character '@' 

          - Special characters dot, underscore is allowed

          - max length limit

          and so on.

     

     

    Regards

    Kareem



  • 2.  Re: Query Parameter format or pattern validation.
    Best Answer

    Posted Jan 08, 2017 01:56 AM

    We can implement this functionality using regular expressions in Compare Expressions assertions. 

     

    1 - Add Compare Expression assertion.

    2 - Select 'Expression' and enter email parameter values ex: ${request.http.parameter.email}

    3 - For Rules click 'Add' button.

    4. - From Rule Selection pop-up select rule type 'Regular Expression' from the drop down options. 

    5 - Provide regular expression to validate the email format. For example:

          [A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}

     

    For more information on regular expressions visit below URL:
    Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns 

     

     

    Regards

    Kareem