diff --git a/packtools/sps/validation/app_group.py b/packtools/sps/validation/app_group.py index d1553939a..4219cacd4 100644 --- a/packtools/sps/validation/app_group.py +++ b/packtools/sps/validation/app_group.py @@ -1,5 +1,5 @@ from packtools.sps.models.app_group import XmlAppGroup -from packtools.sps.validation.utils import format_response +from packtools.sps.validation.utils import build_response class AppValidation: @@ -9,36 +9,54 @@ def __init__(self, xmltree, params): self.params = params def validate(self): + """ + Executa todas as validações para e . + + Yields: + dict: Resultados de validação + """ yield from self.validate_app_existence() + yield from self.validate_app_id() + yield from self.validate_app_label() + yield from self.validate_app_group_wrapper() + yield from self.validate_media_accessibility() def validate_app_existence(self): + """ + Valida a existência de elementos . + + Nota: é opcional segundo SciELO, mas esta validação + fornece informação útil aos editores. + + Yields: + dict: Resultado de validação (nível informativo) + """ if not self.apps: - yield format_response( - title="", - parent="article", - parent_id=None, - parent_article_type=self.xmltree.get("article-type"), - parent_lang=self.xmltree.get( - "{http://www.w3.org/XML/1998/namespace}lang" - ), + yield build_response( + title=" element", + parent={ + "parent": "article", + "parent_id": None, + "parent_article_type": self.xmltree.get("article-type"), + "parent_lang": self.xmltree.get("{http://www.w3.org/XML/1998/namespace}lang"), + }, item="app-group", sub_item="app", validation_type="exist", is_valid=False, expected=" element", obtained=None, - advice="Consider adding an element to include additional content such as supplementary materials or appendices.", + advice="Consider adding an element to include additional content such as appendices.", data=None, error_level=self.params["app_existence_error_level"], + advice_text="Consider adding an element to include additional content such as appendices.", + advice_params={} ) else: for app in self.apps: - yield format_response( - title="", - parent=app.get("parent"), - parent_id=app.get("parent_id"), - parent_article_type=app.get("parent_article_type"), - parent_lang=app.get("parent_lang"), + yield build_response( + title=" element", + parent=app, item="app-group", sub_item="app", validation_type="exist", @@ -48,4 +66,211 @@ def validate_app_existence(self): advice=None, data=app, error_level=self.params["app_existence_error_level"], + advice_text=None, + advice_params=None + ) + + def validate_app_id(self): + """ + Valida presença obrigatória do atributo @id em . + + Regra SciELO: "Atributo obrigatório para : @id" + + Yields: + dict: Resultado de validação (CRITICAL se ausente) + """ + for app in self.apps: + app_id = app.get("id") + is_valid = bool(app_id) + + yield build_response( + title=" @id attribute", + parent=app, + item="app", + sub_item="@id", + validation_type="exist", + is_valid=is_valid, + expected="@id attribute in ", + obtained=app_id if is_valid else None, + advice='Add @id attribute to . Example: ', + data=app, + error_level=self.params["app_id_error_level"], + advice_text='Add @id attribute to . Example: ', + advice_params={ + "example_id": "app1" + } + ) + + def validate_app_label(self): + """ + Valida presença obrigatória do elemento