You need to sign in to do that
Don't have an account?
cased1919
Validating multiple number formats in one validation rule
I'm attempting to validate a postal code for a country that currently has two different postal code formats (9999 and/or 9999-999)
Currently I'm trying the following:
IF ((
Country__r.Name = 'Portugal') &&
(LEN( Zip_Postal_Code__c) >1),
(NOT(REGEX(Zip_Postal_Code__c , "[0-9]{4}")) || NOT(REGEX(Zip_Postal_Code__c , "[0-9]{4}-[0-9]{3}"))),
NULL)
What would be the proper syntax for including two formats in one validation rule?
Thanks!
try the following. when ever the country is portugal zip code should be one of the formats ("[0-9]{4}" or "[0-9]{4}-[0-9]{3}"
). you can add any additional formats easily.
AND(
Country__r.Name = 'Portugal',
NOT( REGEX( Zip_Postal_Code__c , "[0-9]{4}") ),
NOT( REGEX( Zip_Postal_Code__c , "[0-9]{4}-[0-9]{3}") )
)
All Answers
try the following. when ever the country is portugal zip code should be one of the formats ("[0-9]{4}" or "[0-9]{4}-[0-9]{3}"
). you can add any additional formats easily.
AND(
Country__r.Name = 'Portugal',
NOT( REGEX( Zip_Postal_Code__c , "[0-9]{4}") ),
NOT( REGEX( Zip_Postal_Code__c , "[0-9]{4}-[0-9]{3}") )
)
Thank you SrikanthKuruva for the help!!
For future views, below is my modified version since I only want to validate when a user fills in a value into this field.
IF ((
Country__r.Name = 'Portugal') &&
(LEN( Zip_Postal_Code__c) >1),
AND(
NOT( REGEX( Zip_Postal_Code__c , "[0-9]{4}") ),
NOT( REGEX( Zip_Postal_Code__c , "[0-9]{4}-[0-9]{3}") )
),
NULL)