Make file validation synchronous and throw errors for validation before starting the promise chain