Keep them separate, because they are different rules that only happen to match today
Keep them separate. DRY (Don't Repeat Yourself) is about duplicated knowledge, not duplicated text. These two rules have different owners and will change for different reasons.
"Extract a shared isValidLength(value) helper" or a shared ValidationConstants.MIN_LENGTH would tie a security policy to a marketing format. If marketing changes the coupon length, password security changes by accident. Merging them is the wrong abstraction, not good DRY.
Read more