Add validation to codes
Fix codes controller