trigger ValidNumber on Contact (before insert) { String phonePattern = '(123) 456-7890'; for (Contact contact : Trigger.New) { if (!Pattern.matches(phonePattern, contact.Phone)) { contact.Phone.addError('Invalid phone format!'); } } }