completed assignment
This commit is contained in:
14
force-app/main/default/triggers/ValidNumber.trigger
Normal file
14
force-app/main/default/triggers/ValidNumber.trigger
Normal file
@@ -0,0 +1,14 @@
|
||||
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!');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user