Validate (Assert) numerical data from rest request

Validate (Assert) numerical data from rest request

Home Forums Ask Expert Validate (Assert) numerical data from rest request

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #32348
    Alan Carr
    Participant

      Hi

      I have been using the “check list” feature to validate the response from a rest api’s. I now wish to use numeric comparison such as greater / less than / equal to etc of the returned data Eg the returned data = 5 and I wish to compare less than or equal to 5.

      I am using zap test in the non scripted mode..

      #32350
      Valentin ZAP
      Keymaster

        Hello Alan!

        Fo non-scripted mode you can use write a “Regular Expression” to validate number (less/equal). To use Regular Expressions in ZAPTEST method, don’t forget to enable “Use RegExps” method property.

        Current SCRIPT-LESS version doesn’t have an alternative way to compare number.

        Thank you,
        ZAPTEST Team

        #32351
        Valentin ZAP
        Keymaster

          Hello Alan!

          PS. You can use If/Else conditions for comparing some specific results. Please refer to Script-Less tutorials, how to write such script and use variables in Script-Less mode.

          Thank you,
          ZAPTEST Team

          #32352
          Alan Carr
          Participant

            Hi

            I’m confused, I’m using step view with reg exp true.

            I have my “check list” how do I enter into the check list my conditions for numeric data

            p.s What is the difference between SCRIPT-LESS and non scripted are they not the same ?

            #32353
            Valentin ZAP
            Keymaster

              Hello Alan!

              Yes, Script-Less and Non-Scripted sentences have the same meaning.

              For checking value you could write a simple regular expression, where:


              d - numbers 0-9
              1d - numbers 10-19
              2[0-5] - numbers 20-25
              (x|y|z) - one of x, y or z

              So, in your case, you can accept only 0, 1, 2, 3, 4, 5 numbers, which is “[0-5]“.

              Thank you,
              ZAPTEST Team

            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.

            Virtual Expert

            ZAPTEST

            ZAPTEST Logo