Skip to content

Commit cd6655b

Browse files
committed
fix predicate validator
1 parent abaa0b0 commit cd6655b

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

airbyte_cdk/sources/declarative/validators/predicate_validator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
from typing import Any
77

88
from airbyte_cdk.sources.declarative.validators.validation_strategy import ValidationStrategy
9+
from airbyte_cdk.sources.declarative.validators.validator import Validator
910

1011

1112
@dataclass
12-
class PredicateValidator:
13+
class PredicateValidator(Validator):
1314
"""
1415
Validator that applies a validation strategy to a value.
1516
"""
1617

1718
value: Any
1819
strategy: ValidationStrategy
1920

20-
def validate(self) -> None:
21+
def validate(self, input_data: Any) -> None:
2122
"""
2223
Applies the validation strategy to the value.
2324

unit_tests/sources/declarative/validators/test_predicate_validator.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
2+
13
from unittest import TestCase
24

35
import pytest
@@ -26,7 +28,7 @@ def test_given_valid_input_validate_is_successful(self):
2628
test_value = "test@example.com"
2729
validator = PredicateValidator(value=test_value, strategy=strategy)
2830

29-
validator.validate()
31+
validator.validate(input_data={})
3032

3133
assert strategy.validate_called
3234
assert strategy.validated_value == test_value
@@ -38,7 +40,7 @@ def test_given_invalid_input_when_validate_then_raise_value_error(self):
3840
validator = PredicateValidator(value=test_value, strategy=strategy)
3941

4042
with pytest.raises(ValueError) as context:
41-
validator.validate()
43+
validator.validate(input_data={})
4244

4345
assert error_message in str(context.value)
4446
assert strategy.validate_called
@@ -49,7 +51,7 @@ def test_given_complex_object_when_validate_then_successful(self):
4951
test_value = {"user": {"email": "test@example.com", "name": "Test User"}}
5052
validator = PredicateValidator(value=test_value, strategy=strategy)
5153

52-
validator.validate()
54+
validator.validate(input_data={})
5355

5456
assert strategy.validate_called
5557
assert strategy.validated_value == test_value

0 commit comments

Comments
 (0)