function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shweta DwivediShweta Dwivedi 

validation rule using Regex

Create a validation rule on a 12 digit number field for the following condition.  
1) All 12 digit number should not be same. (1111 1111 1111),  
2) 3 consecutive numbers should not be same (1112 2223 3334) ,
3) Field length= 12.

 
Best Answer chosen by Shweta Dwivedi
PulaK_PrabhakaRPulaK_PrabhakaR
Change Data Type of that 12 digit number field into Text data type field of length 12. 
  Use the below-mentioned formula to satisfy all the conditions and give a proper error message.
     (Note:- It will only accept numbers)

Lets suppose name of the field is "NoRepeat__c".
OR(NOT(ISNUMBER(NoRepeat__c)),
   CONTAINS(NoRepeat__c, '111'),
   CONTAINS(NoRepeat__c, '222'),
   CONTAINS(NoRepeat__c, '333'),
   CONTAINS(NoRepeat__c, '444'),
   CONTAINS(NoRepeat__c, '555'),
   CONTAINS(NoRepeat__c, '666'),
   CONTAINS(NoRepeat__c, '777'),
   CONTAINS(NoRepeat__c, '888'),
   CONTAINS(NoRepeat__c, '999'),
   CONTAINS(NoRepeat__c, '000'))

Please mark the answer as best answer if the information is informative so that the question is removed from an unanswered question and appear as a proper solution.