Separate validation rule into a specific method.

It allows the rule to be used in several locations instead of
duplicating the code.