# Make "Path Variable" required for Sending the request

**URL:** <https://community.postman.com/t/make-path-variable-required-for-sending-the-request/21722>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [March 23, 2021, 9:32am UTC](https://community.postman.com/t/make-path-variable-required-for-sending-the-request/21722 "2021-03-23T09:32:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mandrasdt](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mandrasdt](https://community.postman.com/u/mandrasdt)\
**Post date:** [March 23, 2021, 9:32am UTC](https://community.postman.com/t/make-path-variable-required-for-sending-the-request/21722/1 "2021-03-23T09:32:05Z")

</div>

Hi Team,  
I have a Path Variable (imported as openapi) but I can Send the request if the field is empty.  
(In Swagger this is not possible, as there is a field validation (empty))  
Is there any option in Postman to force users to fill out the required field before send?

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/e/1/e1d57ca001e36fe91c12ef1c2d978e55099e2c9b.png)

---

<div class="post-metadata">

**Author:** ![Kurmavatar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kurmavatar/32/3026_2.png) [@Kurmavatar](https://community.postman.com/u/Kurmavatar)\
**Post date:** [March 23, 2021, 9:41am UTC](https://community.postman.com/t/make-path-variable-required-for-sending-the-request/21722/2 "2021-03-23T09:41:37Z")

</div>

Hi @mandrasdt

Welcome to the community 👋

Looks like we have a long-standing feature request for this:

> <https://github.com/postmanlabs/postman-app-support/issues/2847>
>
> Postman Version: 4.10.3 (4.10.3)
> App (Chrome app or Mac app): Mac app
> OS details: 10.12.3 (16D32)
> Is the Interceptor on and enabled in the...

Similar request on [documentation here.](https://github.com/postmanlabs/postman-app-support/issues/9697)

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [March 23, 2021, 9:53pm UTC](https://community.postman.com/t/make-path-variable-required-for-sending-the-request/21722/3 "2021-03-23T21:53:48Z")

</div>

You can prevent the request being send to server by throwing an error in pre-request script:

`pm.request.url.toJSON().variable.filter((elem) => elem.value === "").map(elem => elem.key).includes("v2") ? (() => {throw Error("Please provide path parameter v2")})(): null`

This code will check if the path parameter v2 (eg [https://something/:v2/something](https://something/:v2/something)) has a value provided else throw the error

![image](https://us1.discourse-cdn.com/getpostman/original/3X/9/8/9812cb2dc5c166540039d181b5dea1c805145df9.png)
