Fix replacing files by adding the missing validate() function for file editing.

#4555