This is validation code. Validation code belongs to models and not to controllers even if it's easier to put it in here.