validates_format_of :order_of_importance, :on => :create, :with => /^[1-3]{3}$/,
:message => "Order of Importance must have 3 Digits"
Right now I have it validating that the numbers used are either 1, 2, 3, but I want to also make sure that those numbers are not only used, but that each one is used only once.
For example:
Should be working numbers
2 3 1
1 3 2
1 2 3
Should not be working numbers:
1 1 2
2 2 1
3 3 3
Isn’t it easier to check against all 3! valid permutations?
Edit:
But to take you up on the challenge:
(?:1(?!\d*1)|2(?!\d*2)|3(?!\d*3)){3}It uses negative lookaheads to make sure numbers are picked only once.
Edit:
Checked with rubular.com.