Check if filed gender is 1 or 2 with Postman

how can i test if field “gender” is 1 or 2 Please?

“naturalPerson”: {
“fullName”: “Teste with Luis”,
“nickName”: “Pacheco”,
“gender”: 2,
“pronoun”: 2,

Hi @silvio.aulik

Assuming your response looks like this:

{
    "naturalPerson": {
        "fullName": "Teste with Luis",
        "nickName": "Pacheco",
        "gender": 2,
        "pronoun": 2
    }
}

Then to check the ‘value is 1 or 2’ you could use the following

const response = pm.response.json();

pm.test("Check value is either 1 or 2", function () {
    pm.expect(response.naturalPerson.gender).to.be.oneOf([1, 2]);
});
1 Like

Your are the best!!.. Thank you x 1000…
Be happy