diff --git a/zyte_spider_templates/params.py b/zyte_spider_templates/params.py index 568de72..497fe9f 100644 --- a/zyte_spider_templates/params.py +++ b/zyte_spider_templates/params.py @@ -83,19 +83,21 @@ class MaxRequestsParam(BaseModel): ) -INPUT_FIELDS = ("url", "urls", "urls_file") +INPUT_GROUP_FIELDS = ("url", "urls", "urls_file") INPUT_GROUP = { "id": "inputs", "title": "Inputs", - "description": ("Input data that determines the start URLs of the crawl."), + "description": "Input data that determines the start URLs of the crawl.", "widget": "exclusive", } -def single_input_validator(model): - input_fields = set(field for field in INPUT_FIELDS if getattr(model, field, None)) +def validate_input_group(model): + input_fields = set( + field for field in INPUT_GROUP_FIELDS if getattr(model, field, None) + ) if not input_fields: - input_field_list = ", ".join(INPUT_FIELDS) + input_field_list = ", ".join(INPUT_GROUP_FIELDS) raise ValueError( f"No input parameter defined. Please, define one of: " f"{input_field_list}." @@ -128,8 +130,8 @@ class UrlsFileParam(BaseModel): ) @model_validator(mode="after") - def single_input(self): - return single_input_validator(self) + def input_group(self): + return validate_input_group(self) class UrlParam(BaseModel): @@ -146,8 +148,8 @@ class UrlParam(BaseModel): ) @model_validator(mode="after") - def single_input(self): - return single_input_validator(self) + def input_group(self): + return validate_input_group(self) class UrlsParam(BaseModel): @@ -167,8 +169,8 @@ class UrlsParam(BaseModel): ) @model_validator(mode="after") - def single_input(self): - return single_input_validator(self) + def input_group(self): + return validate_input_group(self) @field_validator("urls", mode="before") @classmethod