Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom result validators #266

Merged
merged 4 commits into from
Sep 3, 2024
Merged

Add support for custom result validators #266

merged 4 commits into from
Sep 3, 2024

Conversation

jlowin
Copy link
Member

@jlowin jlowin commented Sep 3, 2024

def validate_even(value: int) -> int:
    if value % 2 != 0:
        raise ValueError("Value must be even")
    return value

task = Task(
    "choose an even number", result_type=int, result_validator=validate_even
)

task.mark_successful(result=4)
assert task.result == 4

@jlowin jlowin added the feature New feature that doesn't exist today label Sep 3, 2024
@jlowin jlowin merged commit c1da92e into main Sep 3, 2024
3 checks passed
@jlowin jlowin deleted the validate branch September 3, 2024 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that doesn't exist today
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant