Fix hidden bug in validate_* functions