here is my validation rule




I am Entering contact in test class

Contact con = new Contact();
con.firstname = 'Test';
con.lastname = 'Warner';
con.AccountId = acc.id;
insert con;

First Character is Capital and not special character allow. i'm following this validation but it throw error in test class is

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Special characters are not allowed in contacts First Name / Last Name: []


This has nothing to do with the test class. The validation seems to fail even while creating a contact with no special character in the first name.

The condition NOT(REGEX(LEFT(FirstName,1),"[\p{L}\s.]$"))) and (REGEX(LEFT(FirstName,1),"[\p{L}\s.]$"))) are contradicting conditions. One of them is going to be true. I think the third condition for the OR should be removed:(REGEX(LEFT(FirstName,1),"[\p{L}\s.]$")))

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.