Validation Rules Interview Questions and Answers Experienced

1.What do you mean by a validation Rule.

Ans: A validation rule is some set of conditions. If the condition gets satified, then it gives error.

2.What are the Types of Validation Rules.

Ans:
A] System Validation Rule    (Salesforce Default)
B] Custom Validation Rule   (Developer Created)

3. What is validation rule governor limits.

Ans:

Limit Type Limit Description
Formula Size 3,900 characters Number of characters you can type in the formula editor
Number of Referenced Fields 60 fields Total number of unique fields referenced in the formula
Number of Validation Rules Per Object 100 Active rules (Developer Edition)
500 Active rules (Unlimited Edition)
Maximum number of active validation rules per object

Note - Generally in then Company, we use Unlimited Edition etc., and not use Developer Edition.

4. Does Validation rule works for Delete operation

Ans: No. Not Possible. Works only for Create and Update operations.

5. Using Validation rule, How to prevent Account record deletion, if Rating is Hot.

Ans: Validation Rules cannot prevent record deletion in Salesforce — they only work when creating or editing records.
Solution:
A] User Lightning Record Triggered Flow (Delete event with custom error)
B] Use trigger (Apex Trigger) on Account's before delete event.

6. Can we Bypass a validation rule?
I have created a validation rule, which prevent Account Record insert/update, when its Rating is Hot. So, when I manually create the Account record with Rating Hot, it is giving me Error, which us perfectly fine. Okay?
Now, when I upload Account records using Data Migration Tools (e.g Data Loader / Workbench) with Rating Hot, it should allow me. Means validation rule should not give me error. How can you achieve this.

Ans:sYes, it is possible.
A] Create a Checkbox field on Account, e.g., Bypass_Validation__c, By Default: Unchecked (You can hide this field from page pageLout too)
B] Validation Rule
AND( Rating = "Hot", NOT(Bypass_Validation__c) )

This means: Validation rule triggers only if Bypass_Validation__c is NOT checked.

C] While doing Data Loader / Workbench upload, set Bypass_Validation__c = TRUE for records you want to bypass validation.

Result:
Manual insert/update --> FALSE (unchecked) --> Validation rule triggers
Data Loader insert/update --> TRUE (checked) --> Validation rule bypassed

7. Prevent Contact's Blank Email Id.

Ans: ISBLANK(Email)

8. Prevent special symbols and number in the Contact FirstName.

Ans: As it is Pattern Matching, so use REGEX (Regular Expression)
NOT( REGEX(FirstName, "^[A-Za-z ]+$") )

9. Prevent special symbols and number in the Contact FirstName and LastName.

Ans: NOT(REGEX(FirstName, "^[A-Za-z ]+$")) || NOT(REGEX(LastName, "^[A-Za-z ]+$"))

10. Prevent Contact, if age is less than 18.

Ans: (TODAY() - Birthdate) / 365 < 18

11. Prevent Account if Rating is Hot and Type is Prospect.

Ans: AND( Rating = "Hot", Type = "Prospect" )

12. Prevent Account if Rating is Hot or Warm and Type is Prospect or Other.

Ans: AND( OR(Rating = "Hot", Rating = "Warm"), OR(Type = "Prospect", Type = "Other") )

Prevent Invalid Pan Card Number.

Ans: NOT( REGEX(PAN_Number__c, "^[A-Za-z]{5}[0-9]{4}[A-Za-z]$") )

14. Don't allow small letters in the Pan Card.

Ans: NOT( REGEX(PAN_Number__c, "^[A-Z]{5}[0-9]{4}[A-Z]$") )

15. Contact Email Id should be mandatory for 'Customer Care' profile only. Not for other profiles.

Ans: AND( $Profile.Name = "Customer Care", ISBLANK(Email) )

16. Contact Email Id should be mandatory for 'Ganesh Padole' user only. Not for other users.

Ans: AND( $User.Name = "Ganesh Padole", ISBLANK(Email) )

Another Solution

AND( $User.Id = "005xxxxxxxxxxxxxxx", /* Replace with Ganesh Padole's UserId */ ISBLANK(Email) )

17. How do you make a field mandatory only for certain Profiles or Roles?

Ans: Use $Profile.Name or $UserRole.Name in the Validation Rule.

18. How to conditionally require a field based on another field’s value? Example: Email mandatory only if Lead Source = 'Web'.

Ans: AND( ISPICKVAL(LeadSource, "Web"), ISBLANK(Email) )

19. How to prevent special characters or numbers in name fields?/h4>

Ans: Using REGEX

20. How do you enforce proper formatting for IDs like PAN, GSTIN, or Phone Number?

Ans: Regex validation with pattern matching.