Validation rules for Country codes(USA, Mexico, Argentina, Canada, Australia) in Salesforce

Validation rules for Country codes(USA, Mexico, Argentina, Canada, Australia) in Salesforce

Example:

OR(

AND(

ISPICKVAL( Country_Code__c , “USA”),NOT( REGEX( Pincode__c , “\d{5}(-\d{4})?”) )

),

AND(

ISPICKVAL( Country_Code__c , “MEX”), NOT(REGEX( Pincode__c , “\d{5}”)), NOT(REGEX( Pincode__c , “\d{6}”))

),

AND(

ISPICKVAL( Country_Code__c , “AUS”), NOT(REGEX( Pincode__c , “\d{4}”))

),

AND(

ISPICKVAL( Country_Code__c , “CAN”), NOT(REGEX( Pincode__c , “[a-zA-Z]{1}[0-9]{1}[a-zA-Z]{1}\s[0-9]{1}[a-zA-Z]{1}[0-9]{1}”))

),

AND(

ISPICKVAL( Country_Code__c , “ARG”), NOT(REGEX( Pincode__c ,
“[a-zA-Z]{1}\d{4}[a-zA-Z]{3}”)),NOT(REGEX( Pincode__c , “\d{4}”))

)

)

Leave a Reply