This could probably be refactored into an associative array. It might also be worthwhile to move the error message generation into a separate (private) method.