Extract safeGetPath out of validateRequiredProperty and bug fix

/cc @jwswj