The chess piece must only be moved if it does not violate the rules of the game. For example, a chess piece can move to a valid location only if that location is not already occupied by a chess piece of the same color. Similarly, a piece can move only if it is the player's turn to move. Another rule states that a piece can only move if the resulting move does not result in check for the king of the same color.
This pre_move_validation method is responsible for checking all the rules. If all validations pass, it calls the move method to update the move, as follows (see 4.06—model.py):
def pre_move_validation(self, initial_pos, final_pos): initial_pos, final_pos = initial_pos.upper(), final_pos.upper() piece = self.get_piece_at(initial_pos) ...