Skip to content

Validators

audit_repo_exists(value, context)

Check if the repository with the given name is registered.

PARAMETER DESCRIPTION
value

The repository name.

TYPE: Any

context

The CKAN context.

TYPE: Context

RETURNS DESCRIPTION
Any

The repository name if it exists.

TYPE: Any

RAISES DESCRIPTION
Invalid

If the repository does not exist.

Source code in ckanext/event_audit/logic/validators.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def audit_repo_exists(value: Any, context: Context) -> Any:
    """Check if the repository with the given name is registered.

    Args:
        value (Any): The repository name.
        context (Context): The CKAN context.

    Returns:
        Any: The repository name if it exists.

    Raises:
        tk.Invalid: If the repository does not exist.
    """
    if value not in utils.get_available_repos():
        raise tk.Invalid(f"Repository `{value}` is not registered")

    return value