Updated the checkExpectedType method in the validator