# pega validation

**URL:** <https://forums.pega.com/t/pega-validation/3346>\
**Category:** User Experience\
**Tags:** dev-designer-studio, 8-7-3, user-experience\
**Created:** [October 12, 2022, 9:19am UTC](https://forums.pega.com/t/pega-validation/3346 "2022-10-12T09:19:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sahanc38](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/sahanc38/32/7241_2.png) [@sahanc38](https://forums.pega.com/u/sahanc38)\
**Post date:** [October 12, 2022, 9:19am UTC](https://forums.pega.com/t/pega-validation/3346/1 "2022-10-12T09:19:34Z")

</div>

I want to apply validation for DOB field 17y \< Age \< 81y, how can I do that?

---

<div class="post-metadata">

**Author:** ![Satish\_K\_Sudagoni1](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/satish_k_sudagoni1/32/17763_2.png) [@Satish\_K\_Sudagoni1](https://forums.pega.com/u/Satish_K_Sudagoni1)\
**Post date:** [October 12, 2022, 10:05am UTC](https://forums.pega.com/t/pega-validation/3346/2 "2022-10-12T10:05:08Z")

</div>

@sahanc38

validate rule and add it in flow action. see the screenshot for code

 ![Validate1.png](https://pega1.discourse-cdn.com/pega/original/2X/7/7da387f6936b3e8a97ac25f545e974d06b88d885.png)

 ![error when age is less than 17.png](https://pega1.discourse-cdn.com/pega/original/2X/4/40a6ba681bb7e570e77818498417a3cad4afc9d4.png)

 ![error when age is greater than 81.png](https://pega1.discourse-cdn.com/pega/original/2X/5/5e228b107774dffc222682626327338ef3e802aa.png)

---

<div class="post-metadata">

**Author:** ![SanthoshRanga](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/santhoshranga/32/3113_2.png) [@SanthoshRanga](https://forums.pega.com/u/SanthoshRanga)\
**Post date:** [October 12, 2022, 11:41am UTC](https://forums.pega.com/t/pega-validation/3346/3 "2022-10-12T11:41:44Z")

</div>

@sahanc38 If you want to validate based on given date of birth and not age then use a validate rule and then select expression and use below expression

@DateTimeDifference(@dateValue(.DateOfBirth),@dateValue(@today()),“Y”) and then check for the value if its less than 17 or greater than 81.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Satish\_K\_Sudagoni1](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/satish_k_sudagoni1/32/17763_2.png) [@Satish\_K\_Sudagoni1](https://forums.pega.com/u/Satish_K_Sudagoni1)\
**Post date:** [October 12, 2022, 2:26pm UTC](https://forums.pega.com/t/pega-validation/3346/4 "2022-10-12T14:26:23Z")

</div>

@sahanc38 oh yes I missed DOB in the question.

do as Santosh said

@DateTimeDifference(@dateValue(.DateOfBirth),@dateValue(@today()),“Y”) and then check for the value if its less than 17 or greater than 81.
