It would replace everything you have.
Put it in a file of its own then take a copy of the original form and point the action to this script instead. This would let you test it with various good and bad input parameters.
Beyond this point you would check to see if the $aErrorMessages is empty. If it is, validation passed the input values and you can continue processing. Otherwise it failed, and you can show the error messages in the $aErrorMessages array.