Pull Request 

I think this part should be done in model using the built in validate() method.