# Schema validation involving "dependentRequired" statements not working as expected

**URL:** <https://community.postman.com/t/schema-validation-involving-dependentrequired-statements-not-working-as-expected/39653>\
**Category:** Help Hub\
**Tags:** jsonschema, schemavalidation\
**Created:** [September 30, 2022, 2:04pm UTC](https://community.postman.com/t/schema-validation-involving-dependentrequired-statements-not-working-as-expected/39653 "2022-09-30T14:04:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![haroon.malik](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@haroon.malik](https://community.postman.com/u/haroon.malik)\
**Post date:** [September 30, 2022, 2:04pm UTC](https://community.postman.com/t/schema-validation-involving-dependentrequired-statements-not-working-as-expected/39653/1 "2022-09-30T14:04:56Z")

</div>

I have the following schema which makes use of the **dependentRequired** statement:

```auto
const schema2 = {
    "type": "object",

    "properties": {
        "name": { "type": "string" },
        "credit_card": { "type": "number" },
        "billing_address": { "type": "string" }
    },

    "required": ["name"],

    "dependentRequired": {
        "credit_card": ["billing_address"]
    }
} 

pm.test("Validate dependentRequired Schema", ()=>{
    pm.response.to.have.jsonSchema(schema2);
})

```

The validation is expected to fail for the following scenario where the billing address is missing. This is also working fine when I test it with [https://www.jsonschemavalidator.net/](https://jsonschemavalidator.net) but in Postman, the Test Result is always passing.

```auto
{
"name": "John Doe",
"credit_card": 5555555555555555
}

```

The only way that this works as expected is when I add the **“required”** statement after **dependentRequired** i.e.

```auto
const schema2 = {
    "type": "object",

    "properties": {
        "name": { "type": "string" },
        "credit_card": { "type": "number" },
        "billing_address": { "type": "string" }
    },

    "required": ["name"],

    "dependentRequired": {
        "credit_card": ["billing_address"]
    },
    "required": ["billing_address"]
} 

```

But, doesn’t this defeat the purpose of using **“dependentRequired”**?
