Fix #4555 by adding the missing validate() function.
Merge pull request #4823 from openscholar/4555

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