def _validate(self, sam_template, parameter_values):
if parameter_values is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if ("<STR_LIT>" not in sam_template or not isinstance(sam_template["<STR_LIT>"], dict) or not<EOL>sam_template["<STR_LIT>"]):<EOL><INDENT>raise InvalidDocumentException(<EOL>[InvalidTemplateException("<STR_LIT>")])<EOL><DEDENT>if (not all(isinstance(sam_resource, dict) for sam_resource in sam_template["<STR_LIT>"].values())):<EOL><INDENT>raise InvalidDocumentException(<EOL>[InvalidTemplateException(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)])<EOL><DEDENT>sam_template_instance = SamTemplate(sam_template)<EOL>for resource_logical_id, sam_resource in sam_template_instance.iterate():<EOL><INDENT>if (not isinstance(sam_resource.properties, dict)):<EOL><INDENT>raise InvalidDocumentException(<EOL>[InvalidResourceException(resource_logical_id,<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)])<EOL><DEDENT><DEDENT>SamTemplateValidator.validate(sam_template)<EOL>
Validates the template and parameter values and raises exceptions if there's an issue

        :param dict sam_template: SAM template
        :param dict parameter_values: Dictionary of parameter values provided by the user