# I try to validate login message but password is correct it also reflect 2nd condition also

**URL:** <https://community.postman.com/t/i-try-to-validate-login-message-but-password-is-correct-it-also-reflect-2nd-condition-also/26324>\
**Category:** Help Hub\
**Created:** [July 31, 2021, 4:19am UTC](https://community.postman.com/t/i-try-to-validate-login-message-but-password-is-correct-it-also-reflect-2nd-condition-also/26324 "2021-07-31T04:19:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![science-astronaut-50](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@science-astronaut-50](https://community.postman.com/u/science-astronaut-50)\
**Post date:** [July 31, 2021, 4:19am UTC](https://community.postman.com/t/i-try-to-validate-login-message-but-password-is-correct-it-also-reflect-2nd-condition-also/26324/1 "2021-07-31T04:19:38Z")

</div>

I try to validate login message but password is correct it also reflect 2nd condition also.

var jsonData1 = pm.response.json();

```
if (pm.response.json().success == true) {

pm.test("Login Successfull", function () {

    pm.expect(jsonData1.msg).to.be.eql("Login Successfull")

}); 

} else (pm.response.json().success == false)

pm.test("Incorrect Password" , function () {

    pm.expect(jsonData1.msg).to.be.eql("Incorrect Password")

});

```

_My question_:  
How to use if else condition for validate message for login

I found  
{Incorrect Password | AssertionError: expected ‘Login Successfull’ to deeply equal ‘Incorrect Password’ } this also.  
 ![Postman 31-07-2021 09_48_34 (2)](https://us1.discourse-cdn.com/getpostman/original/2X/3/3ca401acc05780e0da0512f7d27bf1efda949728.png)

---

<div class="post-metadata">

**Author:** ![neilstudd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/neilstudd/32/8213_2.png) [@neilstudd](https://community.postman.com/u/neilstudd)\
**Post date:** [July 31, 2021, 8:01pm UTC](https://community.postman.com/t/i-try-to-validate-login-message-but-password-is-correct-it-also-reflect-2nd-condition-also/26324/2 "2021-07-31T20:01:03Z")

</div>

This has been superceded by a follow-up topic:

> [@Using if else statement condition for login test](https://community.postman.com/t/using-if-else-statement-condition-for-login-test/26323/):
>
> Your question may already have an answer on the community forum. Please search for related topics, and then read through the [guidelines](https://community.postman.com/t/about-the-just-getting-started-category/37) before creating a new topic. Here’s an outline with best practices for making your inquiry. My question: Details (like screenshots): I am using if else statement condition for login test and try to success value should be in true and should be match msg for all different condition in body value let jsonData1 = pm.response.json(), msg = ["Login Successfu…

Therefore, I will close this topic.

---

<div class="post-metadata">

**Author:** ![neilstudd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/neilstudd/32/8213_2.png) [@neilstudd](https://community.postman.com/u/neilstudd)\
**Post date:** [July 31, 2021, 8:01pm UTC](https://community.postman.com/t/i-try-to-validate-login-message-but-password-is-correct-it-also-reflect-2nd-condition-also/26324/3 "2021-07-31T20:01:13Z")

</div>


