# Validation rule for "-", automatic

**URL:** <https://forums.pega.com/t/validation-rule-for-automatic/7286>\
**Category:** General\
**Tags:** dev-designer-studio, pega-platform, case-management, data-integration\
**Created:** [June 7, 2024, 7:27am UTC](https://forums.pega.com/t/validation-rule-for-automatic/7286 "2024-06-07T07:27:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Praveenn8811](https://avatars.discourse-cdn.com/v4/letter/p/8baadc/32.png) [@Praveenn8811](https://forums.pega.com/u/Praveenn8811)\
**Post date:** [June 7, 2024, 7:27am UTC](https://forums.pega.com/t/validation-rule-for-automatic/7286/1 "2024-06-07T07:27:27Z")

</div>

Hi,

I have a requirement, system should perform the following validations for particular ID.

should be numeric, the user should not be able to enter text, should be 9 digits and should follow the following format: xxx-xx-xxxx. The dash should be automatically written by the system. There will be no access for special characters. So, please suggest me best solution to achieve.

---

<div class="post-metadata">

**Author:** ![Tushar\_Banerjee1](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/tushar_banerjee1/32/22442_2.png) [@Tushar\_Banerjee1](https://forums.pega.com/u/Tushar_Banerjee1)\
**Post date:** [June 7, 2024, 8:10am UTC](https://forums.pega.com/t/validation-rule-for-automatic/7286/2 "2024-06-07T08:10:51Z")

</div>

Hi @Praveenn881

Hope this helps :

> **[Need an Edit Validate rule xxx-xxxxx in the format](https://forums.pega.com/question/need-edit-validate-rule-xxx-xxxxx-format)**
>
> Hi, We have a requirement like there is a filed which is allowed only integers and the first digit should starts with “4” ,there should be a “-” after three digits and it should be in the format like 4xx-xxxxx(eg:432-87613).I was created an edit...

Thanks

---

<div class="post-metadata">

**Author:** ![SohamM95](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/sohamm95/32/4726_2.png) [@SohamM95](https://forums.pega.com/u/SohamM95)\
**Post date:** [June 7, 2024, 8:45am UTC](https://forums.pega.com/t/validation-rule-for-automatic/7286/3 "2024-06-07T08:45:49Z")

</div>

@Praveenn881

You can use an edit validate rule. You can also create a DT/Activity where first you can check the validation of the user input against alphabets and special characters, then after the validation passes you can substring the input into 3 params and concatenate those with ‘-’ in between.

---

<div class="post-metadata">

**Author:** ![Sai\_Guggilla](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/sai_guggilla/32/11575_2.png) [@Sai\_Guggilla](https://forums.pega.com/u/Sai_Guggilla)\
**Post date:** [June 7, 2024, 8:52am UTC](https://forums.pega.com/t/validation-rule-for-automatic/7286/4 "2024-06-07T08:52:24Z")

</div>

Hi @Praveenn881,

we achieve this by creating edit input rule in that rule add the below code.

if (theValue.length() \> 3 && theValue.charAt(3)!=‘-’)

{ StringBuilder sb = new StringBuilder(theValue);

theValue=sb.insert(3, ‘-’).toString();

}

 ![Edit Input.png](https://pega1.discourse-cdn.com/pega/original/2X/1/1806adde47c8b16816084b183aeffe1e8fb7fe96.png)

Thanks,

Sai G

---

<div class="post-metadata">

**Author:** ![Harish\_Kumar](https://avatars.discourse-cdn.com/v4/letter/h/4bbf92/32.png) [@Harish\_Kumar](https://forums.pega.com/u/Harish_Kumar)\
**Post date:** [June 7, 2024, 9:19am UTC](https://forums.pega.com/t/validation-rule-for-automatic/7286/5 "2024-06-07T09:19:27Z")

</div>

Hi @Praveenn881

There is a similar post. You can visit this link [https://support.pega.com/question/need-edit-validate-rule-xxx-xxxxx-format](https://support.pega.com/question/need-edit-validate-rule-xxx-xxxxx-format)

thanks
