def _ValidateMetadataContent(self, metadata_block: syaml.YAML) -> None: """Validates the metadata block and extracts the operation mode. Args: metadata_block: YAML contents of the config metadata block """ mode_str = metadata_block.get(_CONFIG_MODE_KEY, None) if mode_str is not None: self._config_mode = ConfigMode.FromString(mode_str) else: self._config_mode = ConfigMode.Default()
def revalidate_typeschema(type_schema: YAML): """THIS MUTATES `type_schema`! calling the function would change {"number_of_columns": {"value": "1"}} to {"number_of_columns": {"value": 1}} Perform validation on each dictionary in the both lists. This is required due to limitations in strictyaml. See the strictyaml documentation on revalidation for details. This checks that the provided values are valid together while the initial validation only checks that the map is in the right general format.""" for requriment_type in RequirementTypes: for req in type_schema.get(str(requriment_type), []): field = Fields.from_string(req.data["field"]) req.revalidate(field.to_requirements(requriment_type))
def _ValidateEntityBlock(self, block: syaml.YAML) -> None: """Validates a block of entities and adds them to the validated blocks. Args: block: YAML representing one or more entities Raises: ValueError: if block contains a key that has already been found. """ for key in block.keys(): if key in self._validated_entities: raise ValueError('Duplicate key {key}') self._ValidateEntityContent(block.get(key)) self._validated_entities.update(block.data)