[SalesForce] Validation rule to allow certain numbers

I am trying to write a simple validation rule and for some reason i am just not getting it right.

Here is what i want to do

If recordtype = Franchise, then i need to allow only the foll. numbers in Royalty Admin field. 15,18,20,25,30 these are the valid values. If the recordtype is anything other than Franchise then any value is allowed.

Here is what i have got

AND( 
$RecordType.Name = "Franchise", OR( NOT(Royalty_Admin__c = 15) ,NOT(Royalty_Admin__c = 18),NOT(Royalty_Admin__c = 20),NOT(Royalty_Admin__c = 25), NOT(Royalty_Admin__c = 30)) )

This validation rule fires even if i give the right values or wrong values.

UPDATE:@sfdcfox i tried your code and it still fires the validation if enter 18 or 19. Here is the screenshot.

enter image description here
enter image description here

Best Answer

You've confused "OR" with "AND". If the value is 15, for example, then it is not 18. When any of the OR values are true, the entire OR is true. Simply changing this to AND would fix the problem, but there's an easier way:

AND($RecordType.Name = "Franchise", 
  1 = CASE(Royalty_Admin__c, 15, 0, 18, 0, 20, 0, 25, 0, 30, 0, 1)
)

Here, we compare the field to a list of values, returning 0 if it is allowed, 1 if it is not (e.g. this ultimately evaluates to 1 = 1 when no values match, and 1 = 0 when any value matches).


Edit: Percent fields are represented as decimal values (fractions of 1), so you actually need to either use the decimal values (15% = 0.15), or multiply by 100. Here, I multiply by 100:

AND($RecordType.Name = "Franchise", 
  1 = CASE(Royalty_Admin__c * 100, 15, 0, 18, 0, 20, 0, 25, 0, 30, 0, 1)
)