truthound-dashboard 1.4.4__py3-none-any.whl → 1.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- truthound_dashboard/api/alerts.py +75 -86
- truthound_dashboard/api/anomaly.py +7 -13
- truthound_dashboard/api/cross_alerts.py +38 -52
- truthound_dashboard/api/drift.py +49 -59
- truthound_dashboard/api/drift_monitor.py +234 -79
- truthound_dashboard/api/enterprise_sampling.py +498 -0
- truthound_dashboard/api/history.py +57 -5
- truthound_dashboard/api/lineage.py +3 -48
- truthound_dashboard/api/maintenance.py +104 -49
- truthound_dashboard/api/mask.py +1 -2
- truthound_dashboard/api/middleware.py +2 -1
- truthound_dashboard/api/model_monitoring.py +435 -311
- truthound_dashboard/api/notifications.py +227 -191
- truthound_dashboard/api/notifications_advanced.py +21 -20
- truthound_dashboard/api/observability.py +586 -0
- truthound_dashboard/api/plugins.py +2 -433
- truthound_dashboard/api/profile.py +199 -37
- truthound_dashboard/api/quality_reporter.py +701 -0
- truthound_dashboard/api/reports.py +7 -16
- truthound_dashboard/api/router.py +66 -0
- truthound_dashboard/api/rule_suggestions.py +5 -5
- truthound_dashboard/api/scan.py +17 -19
- truthound_dashboard/api/schedules.py +85 -50
- truthound_dashboard/api/schema_evolution.py +6 -6
- truthound_dashboard/api/schema_watcher.py +667 -0
- truthound_dashboard/api/sources.py +98 -27
- truthound_dashboard/api/tiering.py +1323 -0
- truthound_dashboard/api/triggers.py +14 -11
- truthound_dashboard/api/validations.py +12 -11
- truthound_dashboard/api/versioning.py +1 -6
- truthound_dashboard/core/__init__.py +129 -3
- truthound_dashboard/core/actions/__init__.py +62 -0
- truthound_dashboard/core/actions/custom.py +426 -0
- truthound_dashboard/core/actions/notifications.py +910 -0
- truthound_dashboard/core/actions/storage.py +472 -0
- truthound_dashboard/core/actions/webhook.py +281 -0
- truthound_dashboard/core/anomaly.py +262 -67
- truthound_dashboard/core/anomaly_explainer.py +4 -3
- truthound_dashboard/core/backends/__init__.py +67 -0
- truthound_dashboard/core/backends/base.py +299 -0
- truthound_dashboard/core/backends/errors.py +191 -0
- truthound_dashboard/core/backends/factory.py +423 -0
- truthound_dashboard/core/backends/mock_backend.py +451 -0
- truthound_dashboard/core/backends/truthound_backend.py +718 -0
- truthound_dashboard/core/checkpoint/__init__.py +87 -0
- truthound_dashboard/core/checkpoint/adapters.py +814 -0
- truthound_dashboard/core/checkpoint/checkpoint.py +491 -0
- truthound_dashboard/core/checkpoint/runner.py +270 -0
- truthound_dashboard/core/connections.py +645 -23
- truthound_dashboard/core/converters/__init__.py +14 -0
- truthound_dashboard/core/converters/truthound.py +620 -0
- truthound_dashboard/core/cross_alerts.py +540 -320
- truthound_dashboard/core/datasource_factory.py +1672 -0
- truthound_dashboard/core/drift_monitor.py +216 -20
- truthound_dashboard/core/enterprise_sampling.py +1291 -0
- truthound_dashboard/core/interfaces/__init__.py +225 -0
- truthound_dashboard/core/interfaces/actions.py +652 -0
- truthound_dashboard/core/interfaces/base.py +247 -0
- truthound_dashboard/core/interfaces/checkpoint.py +676 -0
- truthound_dashboard/core/interfaces/protocols.py +664 -0
- truthound_dashboard/core/interfaces/reporters.py +650 -0
- truthound_dashboard/core/interfaces/routing.py +646 -0
- truthound_dashboard/core/interfaces/triggers.py +619 -0
- truthound_dashboard/core/lineage.py +407 -71
- truthound_dashboard/core/model_monitoring.py +431 -3
- truthound_dashboard/core/notifications/base.py +4 -0
- truthound_dashboard/core/notifications/channels.py +501 -1203
- truthound_dashboard/core/notifications/deduplication/__init__.py +81 -115
- truthound_dashboard/core/notifications/deduplication/service.py +131 -348
- truthound_dashboard/core/notifications/dispatcher.py +202 -11
- truthound_dashboard/core/notifications/escalation/__init__.py +119 -106
- truthound_dashboard/core/notifications/escalation/engine.py +168 -358
- truthound_dashboard/core/notifications/routing/__init__.py +88 -128
- truthound_dashboard/core/notifications/routing/engine.py +90 -317
- truthound_dashboard/core/notifications/stats_aggregator.py +246 -1
- truthound_dashboard/core/notifications/throttling/__init__.py +67 -50
- truthound_dashboard/core/notifications/throttling/builder.py +117 -255
- truthound_dashboard/core/notifications/truthound_adapter.py +842 -0
- truthound_dashboard/core/phase5/collaboration.py +1 -1
- truthound_dashboard/core/plugins/lifecycle/__init__.py +0 -13
- truthound_dashboard/core/quality_reporter.py +1359 -0
- truthound_dashboard/core/report_history.py +0 -6
- truthound_dashboard/core/reporters/__init__.py +175 -14
- truthound_dashboard/core/reporters/adapters.py +943 -0
- truthound_dashboard/core/reporters/base.py +0 -3
- truthound_dashboard/core/reporters/builtin/__init__.py +18 -0
- truthound_dashboard/core/reporters/builtin/csv_reporter.py +111 -0
- truthound_dashboard/core/reporters/builtin/html_reporter.py +270 -0
- truthound_dashboard/core/reporters/builtin/json_reporter.py +127 -0
- truthound_dashboard/core/reporters/compat.py +266 -0
- truthound_dashboard/core/reporters/csv_reporter.py +2 -35
- truthound_dashboard/core/reporters/factory.py +526 -0
- truthound_dashboard/core/reporters/interfaces.py +745 -0
- truthound_dashboard/core/reporters/registry.py +1 -10
- truthound_dashboard/core/scheduler.py +165 -0
- truthound_dashboard/core/schema_evolution.py +3 -3
- truthound_dashboard/core/schema_watcher.py +1528 -0
- truthound_dashboard/core/services.py +595 -76
- truthound_dashboard/core/store_manager.py +810 -0
- truthound_dashboard/core/streaming_anomaly.py +169 -4
- truthound_dashboard/core/tiering.py +1309 -0
- truthound_dashboard/core/triggers/evaluators.py +178 -8
- truthound_dashboard/core/truthound_adapter.py +2620 -197
- truthound_dashboard/core/unified_alerts.py +23 -20
- truthound_dashboard/db/__init__.py +8 -0
- truthound_dashboard/db/database.py +8 -2
- truthound_dashboard/db/models.py +944 -25
- truthound_dashboard/db/repository.py +2 -0
- truthound_dashboard/main.py +15 -0
- truthound_dashboard/schemas/__init__.py +177 -16
- truthound_dashboard/schemas/base.py +44 -23
- truthound_dashboard/schemas/collaboration.py +19 -6
- truthound_dashboard/schemas/cross_alerts.py +19 -3
- truthound_dashboard/schemas/drift.py +61 -55
- truthound_dashboard/schemas/drift_monitor.py +67 -23
- truthound_dashboard/schemas/enterprise_sampling.py +653 -0
- truthound_dashboard/schemas/lineage.py +0 -33
- truthound_dashboard/schemas/mask.py +10 -8
- truthound_dashboard/schemas/model_monitoring.py +89 -10
- truthound_dashboard/schemas/notifications_advanced.py +13 -0
- truthound_dashboard/schemas/observability.py +453 -0
- truthound_dashboard/schemas/plugins.py +0 -280
- truthound_dashboard/schemas/profile.py +154 -247
- truthound_dashboard/schemas/quality_reporter.py +403 -0
- truthound_dashboard/schemas/reports.py +2 -2
- truthound_dashboard/schemas/rule_suggestion.py +8 -1
- truthound_dashboard/schemas/scan.py +4 -24
- truthound_dashboard/schemas/schedule.py +11 -3
- truthound_dashboard/schemas/schema_watcher.py +727 -0
- truthound_dashboard/schemas/source.py +17 -2
- truthound_dashboard/schemas/tiering.py +822 -0
- truthound_dashboard/schemas/triggers.py +16 -0
- truthound_dashboard/schemas/unified_alerts.py +7 -0
- truthound_dashboard/schemas/validation.py +0 -13
- truthound_dashboard/schemas/validators/base.py +41 -21
- truthound_dashboard/schemas/validators/business_rule_validators.py +244 -0
- truthound_dashboard/schemas/validators/localization_validators.py +273 -0
- truthound_dashboard/schemas/validators/ml_feature_validators.py +308 -0
- truthound_dashboard/schemas/validators/profiling_validators.py +275 -0
- truthound_dashboard/schemas/validators/referential_validators.py +312 -0
- truthound_dashboard/schemas/validators/registry.py +93 -8
- truthound_dashboard/schemas/validators/timeseries_validators.py +389 -0
- truthound_dashboard/schemas/versioning.py +1 -6
- truthound_dashboard/static/index.html +2 -2
- truthound_dashboard-1.5.1.dist-info/METADATA +312 -0
- {truthound_dashboard-1.4.4.dist-info → truthound_dashboard-1.5.1.dist-info}/RECORD +149 -148
- truthound_dashboard/core/plugins/hooks/__init__.py +0 -63
- truthound_dashboard/core/plugins/hooks/decorators.py +0 -367
- truthound_dashboard/core/plugins/hooks/manager.py +0 -403
- truthound_dashboard/core/plugins/hooks/protocols.py +0 -265
- truthound_dashboard/core/plugins/lifecycle/hot_reload.py +0 -584
- truthound_dashboard/core/reporters/junit_reporter.py +0 -233
- truthound_dashboard/core/reporters/markdown_reporter.py +0 -207
- truthound_dashboard/core/reporters/pdf_reporter.py +0 -209
- truthound_dashboard/static/assets/_baseUniq-BcrSP13d.js +0 -1
- truthound_dashboard/static/assets/arc-DlYjKwIL.js +0 -1
- truthound_dashboard/static/assets/architectureDiagram-VXUJARFQ-Bb2drbQM.js +0 -36
- truthound_dashboard/static/assets/blockDiagram-VD42YOAC-BlsPG1CH.js +0 -122
- truthound_dashboard/static/assets/c4Diagram-YG6GDRKO-B9JdUoaC.js +0 -10
- truthound_dashboard/static/assets/channel-Q6mHF1Hd.js +0 -1
- truthound_dashboard/static/assets/chunk-4BX2VUAB-DmyoPVuJ.js +0 -1
- truthound_dashboard/static/assets/chunk-55IACEB6-Bcz6Siv8.js +0 -1
- truthound_dashboard/static/assets/chunk-B4BG7PRW-Br3G5Rum.js +0 -165
- truthound_dashboard/static/assets/chunk-DI55MBZ5-DuM9c23u.js +0 -220
- truthound_dashboard/static/assets/chunk-FMBD7UC4-DNU-5mvT.js +0 -15
- truthound_dashboard/static/assets/chunk-QN33PNHL-Im2yNcmS.js +0 -1
- truthound_dashboard/static/assets/chunk-QZHKN3VN-kZr8XFm1.js +0 -1
- truthound_dashboard/static/assets/chunk-TZMSLE5B-Q__360q_.js +0 -1
- truthound_dashboard/static/assets/classDiagram-2ON5EDUG-vtixxUyK.js +0 -1
- truthound_dashboard/static/assets/classDiagram-v2-WZHVMYZB-vtixxUyK.js +0 -1
- truthound_dashboard/static/assets/clone-BOt2LwD0.js +0 -1
- truthound_dashboard/static/assets/cose-bilkent-S5V4N54A-CBDw6iac.js +0 -1
- truthound_dashboard/static/assets/dagre-6UL2VRFP-XdKqmmY9.js +0 -4
- truthound_dashboard/static/assets/diagram-PSM6KHXK-DAZ8nx9V.js +0 -24
- truthound_dashboard/static/assets/diagram-QEK2KX5R-BRvDTbGD.js +0 -43
- truthound_dashboard/static/assets/diagram-S2PKOQOG-bQcczUkl.js +0 -24
- truthound_dashboard/static/assets/erDiagram-Q2GNP2WA-DPje7VMN.js +0 -60
- truthound_dashboard/static/assets/flowDiagram-NV44I4VS-B7BVtFVS.js +0 -162
- truthound_dashboard/static/assets/ganttDiagram-JELNMOA3-D6WKSS7U.js +0 -267
- truthound_dashboard/static/assets/gitGraphDiagram-NY62KEGX-D3vtVd3y.js +0 -65
- truthound_dashboard/static/assets/graph-BKgNKZVp.js +0 -1
- truthound_dashboard/static/assets/index-C6JSrkHo.css +0 -1
- truthound_dashboard/static/assets/index-DkU82VsU.js +0 -1800
- truthound_dashboard/static/assets/infoDiagram-WHAUD3N6-DnNCT429.js +0 -2
- truthound_dashboard/static/assets/journeyDiagram-XKPGCS4Q-DGiMozqS.js +0 -139
- truthound_dashboard/static/assets/kanban-definition-3W4ZIXB7-BV2gUgli.js +0 -89
- truthound_dashboard/static/assets/katex-Cu_Erd72.js +0 -261
- truthound_dashboard/static/assets/layout-DI2MfQ5G.js +0 -1
- truthound_dashboard/static/assets/min-DYdgXVcT.js +0 -1
- truthound_dashboard/static/assets/mindmap-definition-VGOIOE7T-C7x4ruxz.js +0 -68
- truthound_dashboard/static/assets/pieDiagram-ADFJNKIX-CAJaAB9f.js +0 -30
- truthound_dashboard/static/assets/quadrantDiagram-AYHSOK5B-DeqwDI46.js +0 -7
- truthound_dashboard/static/assets/requirementDiagram-UZGBJVZJ-e3XDpZIM.js +0 -64
- truthound_dashboard/static/assets/sankeyDiagram-TZEHDZUN-CNnAv5Ux.js +0 -10
- truthound_dashboard/static/assets/sequenceDiagram-WL72ISMW-Dsne-Of3.js +0 -145
- truthound_dashboard/static/assets/stateDiagram-FKZM4ZOC-Ee0sQXyb.js +0 -1
- truthound_dashboard/static/assets/stateDiagram-v2-4FDKWEC3-B26KqW_W.js +0 -1
- truthound_dashboard/static/assets/timeline-definition-IT6M3QCI-DZYi2yl3.js +0 -61
- truthound_dashboard/static/assets/treemap-KMMF4GRG-CY3f8In2.js +0 -128
- truthound_dashboard/static/assets/unmerged_dictionaries-Dd7xcPWG.js +0 -1
- truthound_dashboard/static/assets/xychartDiagram-PRI3JC2R-CS7fydZZ.js +0 -7
- truthound_dashboard-1.4.4.dist-info/METADATA +0 -507
- {truthound_dashboard-1.4.4.dist-info → truthound_dashboard-1.5.1.dist-info}/WHEEL +0 -0
- {truthound_dashboard-1.4.4.dist-info → truthound_dashboard-1.5.1.dist-info}/entry_points.txt +0 -0
- {truthound_dashboard-1.4.4.dist-info → truthound_dashboard-1.5.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -509,3 +509,19 @@ class WebhookTriggerResponse(BaseModel):
|
|
|
509
509
|
triggered_schedules: list[str] = Field(default_factory=list)
|
|
510
510
|
message: str
|
|
511
511
|
request_id: str
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
class WebhookTestReceivedData(BaseModel):
|
|
515
|
+
"""Data received in webhook test."""
|
|
516
|
+
|
|
517
|
+
source: str
|
|
518
|
+
event_type: str
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
class WebhookTestResponse(BaseModel):
|
|
522
|
+
"""Response schema for webhook test endpoint."""
|
|
523
|
+
|
|
524
|
+
message: str = Field(..., description="Test result message")
|
|
525
|
+
received: WebhookTestReceivedData = Field(
|
|
526
|
+
..., description="Data that was received in the test request"
|
|
527
|
+
)
|
|
@@ -221,3 +221,10 @@ class BulkAlertActionResponse(BaseModel):
|
|
|
221
221
|
success_count: int = Field(default=0, description="Number of successful updates")
|
|
222
222
|
failed_count: int = Field(default=0, description="Number of failed updates")
|
|
223
223
|
failed_ids: list[str] = Field(default_factory=list, description="IDs that failed")
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class AlertCountResponse(BaseModel):
|
|
227
|
+
"""Response for alert count query."""
|
|
228
|
+
|
|
229
|
+
count: int = Field(..., description="Number of matching alerts")
|
|
230
|
+
status_filter: str = Field(..., description="Status filter applied")
|
|
@@ -102,13 +102,6 @@ class ValidationRunRequest(BaseSchema):
|
|
|
102
102
|
description="Auto-learn and cache schema for validation",
|
|
103
103
|
)
|
|
104
104
|
|
|
105
|
-
# Column filtering
|
|
106
|
-
columns: list[str] | None = Field(
|
|
107
|
-
default=None,
|
|
108
|
-
description="Columns to validate. If None, all columns are validated.",
|
|
109
|
-
examples=[["user_id", "email", "created_at"]],
|
|
110
|
-
)
|
|
111
|
-
|
|
112
105
|
# Severity filtering
|
|
113
106
|
min_severity: Literal["low", "medium", "high", "critical"] | None = Field(
|
|
114
107
|
default=None,
|
|
@@ -116,12 +109,6 @@ class ValidationRunRequest(BaseSchema):
|
|
|
116
109
|
examples=["medium"],
|
|
117
110
|
)
|
|
118
111
|
|
|
119
|
-
# Execution behavior
|
|
120
|
-
strict: bool = Field(
|
|
121
|
-
default=False,
|
|
122
|
-
description="If True, raise exception on validation failures instead of returning results.",
|
|
123
|
-
)
|
|
124
|
-
|
|
125
112
|
# Performance options
|
|
126
113
|
parallel: bool = Field(
|
|
127
114
|
default=False,
|
|
@@ -14,13 +14,18 @@ from pydantic import BaseModel, Field
|
|
|
14
14
|
class ValidatorCategory(str, Enum):
|
|
15
15
|
"""Validator categories matching truthound's classification.
|
|
16
16
|
|
|
17
|
-
Categories are organized by validation purpose:
|
|
17
|
+
Categories are organized by validation purpose (21 total + infrastructure):
|
|
18
18
|
- Core validators: schema, completeness, uniqueness, distribution
|
|
19
19
|
- Format validators: string, datetime
|
|
20
20
|
- Statistical validators: aggregate, anomaly, drift
|
|
21
21
|
- Relational validators: cross_table, multi_column, query
|
|
22
|
-
- Domain validators: table, geospatial, privacy
|
|
23
|
-
-
|
|
22
|
+
- Domain validators: table, geospatial, privacy
|
|
23
|
+
- Business validators: business_rule, profiling, localization
|
|
24
|
+
- ML validators: ml_feature
|
|
25
|
+
- Advanced validators: timeseries, referential
|
|
26
|
+
|
|
27
|
+
Infrastructure modules (not validator categories):
|
|
28
|
+
- sdk, security, i18n, timeout, streaming, memory, optimization
|
|
24
29
|
"""
|
|
25
30
|
|
|
26
31
|
# Core validators (no extra dependencies)
|
|
@@ -47,12 +52,18 @@ class ValidatorCategory(str, Enum):
|
|
|
47
52
|
TABLE = "table"
|
|
48
53
|
GEOSPATIAL = "geospatial"
|
|
49
54
|
PRIVACY = "privacy"
|
|
50
|
-
|
|
55
|
+
|
|
56
|
+
# Business validators
|
|
57
|
+
BUSINESS_RULE = "business_rule"
|
|
58
|
+
PROFILING = "profiling"
|
|
59
|
+
LOCALIZATION = "localization"
|
|
60
|
+
|
|
61
|
+
# ML validators
|
|
62
|
+
ML_FEATURE = "ml_feature"
|
|
51
63
|
|
|
52
64
|
# Advanced validators
|
|
53
|
-
|
|
65
|
+
TIMESERIES = "timeseries"
|
|
54
66
|
REFERENTIAL = "referential"
|
|
55
|
-
STREAMING = "streaming"
|
|
56
67
|
|
|
57
68
|
|
|
58
69
|
class ParameterType(str, Enum):
|
|
@@ -171,20 +182,23 @@ def configs_to_truthound_format(
|
|
|
171
182
|
) -> tuple[list[str] | None, dict[str, dict[str, Any]]]:
|
|
172
183
|
"""Convert ValidatorConfig list to truthound-compatible format.
|
|
173
184
|
|
|
174
|
-
truthound supports two ways of specifying validators:
|
|
185
|
+
truthound 2.x supports two ways of specifying validators:
|
|
175
186
|
1. Simple list of validator names: validators=["Null", "Duplicate"]
|
|
176
|
-
2. Dict-based configuration:
|
|
187
|
+
2. Dict-based configuration: validator_config={"Null": {"columns": ("a", "b")}}
|
|
177
188
|
|
|
178
189
|
This function converts our ValidatorConfig format to both formats,
|
|
179
190
|
allowing the caller to choose based on whether custom params exist.
|
|
180
191
|
|
|
192
|
+
Note: In truthound 2.x, columns parameters should be tuples, not lists.
|
|
193
|
+
This function automatically converts lists to tuples for compatibility.
|
|
194
|
+
|
|
181
195
|
Args:
|
|
182
196
|
configs: List of ValidatorConfig objects from API request.
|
|
183
197
|
|
|
184
198
|
Returns:
|
|
185
|
-
Tuple of (validator_names,
|
|
199
|
+
Tuple of (validator_names, validator_config):
|
|
186
200
|
- validator_names: List of enabled validator names, or None if empty
|
|
187
|
-
-
|
|
201
|
+
- validator_config: Dict of {validator_name: {param: value}} for
|
|
188
202
|
validators with non-default parameters
|
|
189
203
|
|
|
190
204
|
Example:
|
|
@@ -193,14 +207,14 @@ def configs_to_truthound_format(
|
|
|
193
207
|
... ValidatorConfig(name="Duplicate", enabled=True, params={}),
|
|
194
208
|
... ValidatorConfig(name="Range", enabled=False, params={}),
|
|
195
209
|
... ]
|
|
196
|
-
>>> names,
|
|
210
|
+
>>> names, config = configs_to_truthound_format(configs)
|
|
197
211
|
>>> names
|
|
198
212
|
['Null', 'Duplicate']
|
|
199
|
-
>>>
|
|
200
|
-
{'Null': {'columns':
|
|
213
|
+
>>> config
|
|
214
|
+
{'Null': {'columns': ('a',)}}
|
|
201
215
|
"""
|
|
202
216
|
enabled_names: list[str] = []
|
|
203
|
-
|
|
217
|
+
validator_config: dict[str, dict[str, Any]] = {}
|
|
204
218
|
|
|
205
219
|
for config in configs:
|
|
206
220
|
if not config.enabled:
|
|
@@ -211,15 +225,21 @@ def configs_to_truthound_format(
|
|
|
211
225
|
# Only include params that are non-empty
|
|
212
226
|
if config.params:
|
|
213
227
|
# Filter out None, empty strings, and empty lists
|
|
214
|
-
filtered_params = {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
228
|
+
filtered_params: dict[str, Any] = {}
|
|
229
|
+
for k, v in config.params.items():
|
|
230
|
+
if v is None or v == "" or v == []:
|
|
231
|
+
continue
|
|
232
|
+
# Convert lists to tuples for truthound 2.x compatibility
|
|
233
|
+
# (columns parameter should be tuple, not list)
|
|
234
|
+
if isinstance(v, list):
|
|
235
|
+
filtered_params[k] = tuple(v)
|
|
236
|
+
else:
|
|
237
|
+
filtered_params[k] = v
|
|
238
|
+
|
|
219
239
|
if filtered_params:
|
|
220
|
-
|
|
240
|
+
validator_config[config.name] = filtered_params
|
|
221
241
|
|
|
222
|
-
return enabled_names if enabled_names else None,
|
|
242
|
+
return enabled_names if enabled_names else None, validator_config
|
|
223
243
|
|
|
224
244
|
|
|
225
245
|
def has_custom_params(configs: list[ValidatorConfig]) -> bool:
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"""Business rule validators.
|
|
2
|
+
|
|
3
|
+
Validators for domain-specific business rules including checksums,
|
|
4
|
+
financial identifiers (IBAN, VAT), and credit card validation.
|
|
5
|
+
|
|
6
|
+
Import path in truthound: `from truthound.validators.business_rule import *`
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .base import (
|
|
10
|
+
ParameterDefinition,
|
|
11
|
+
ParameterType,
|
|
12
|
+
ValidatorCategory,
|
|
13
|
+
ValidatorDefinition,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
BUSINESS_RULE_VALIDATORS: list[ValidatorDefinition] = [
|
|
17
|
+
ValidatorDefinition(
|
|
18
|
+
name="Checksum",
|
|
19
|
+
display_name="Generic Checksum",
|
|
20
|
+
category=ValidatorCategory.BUSINESS_RULE,
|
|
21
|
+
description="Validates values using a generic checksum algorithm.",
|
|
22
|
+
parameters=[
|
|
23
|
+
ParameterDefinition(
|
|
24
|
+
name="column",
|
|
25
|
+
label="Column",
|
|
26
|
+
type=ParameterType.COLUMN,
|
|
27
|
+
required=True,
|
|
28
|
+
description="Column containing values to validate",
|
|
29
|
+
),
|
|
30
|
+
ParameterDefinition(
|
|
31
|
+
name="algorithm",
|
|
32
|
+
label="Checksum Algorithm",
|
|
33
|
+
type=ParameterType.SELECT,
|
|
34
|
+
options=[
|
|
35
|
+
{"value": "luhn", "label": "Luhn (Mod 10)"},
|
|
36
|
+
{"value": "mod11", "label": "Modulo 11"},
|
|
37
|
+
{"value": "verhoeff", "label": "Verhoeff"},
|
|
38
|
+
{"value": "damm", "label": "Damm"},
|
|
39
|
+
],
|
|
40
|
+
default="luhn",
|
|
41
|
+
description="Checksum algorithm to use",
|
|
42
|
+
),
|
|
43
|
+
],
|
|
44
|
+
tags=["business_rule", "checksum", "validation", "integrity"],
|
|
45
|
+
severity_default="high",
|
|
46
|
+
),
|
|
47
|
+
ValidatorDefinition(
|
|
48
|
+
name="Luhn",
|
|
49
|
+
display_name="Luhn Algorithm (Mod 10)",
|
|
50
|
+
category=ValidatorCategory.BUSINESS_RULE,
|
|
51
|
+
description="Validates values using the Luhn algorithm (credit cards, IMEI, etc.).",
|
|
52
|
+
parameters=[
|
|
53
|
+
ParameterDefinition(
|
|
54
|
+
name="column",
|
|
55
|
+
label="Column",
|
|
56
|
+
type=ParameterType.COLUMN,
|
|
57
|
+
required=True,
|
|
58
|
+
description="Column containing numeric strings to validate",
|
|
59
|
+
),
|
|
60
|
+
],
|
|
61
|
+
tags=["business_rule", "luhn", "mod10", "credit_card"],
|
|
62
|
+
severity_default="high",
|
|
63
|
+
),
|
|
64
|
+
ValidatorDefinition(
|
|
65
|
+
name="ISBN",
|
|
66
|
+
display_name="ISBN Validation",
|
|
67
|
+
category=ValidatorCategory.BUSINESS_RULE,
|
|
68
|
+
description="Validates ISBN-10 or ISBN-13 book identifiers.",
|
|
69
|
+
parameters=[
|
|
70
|
+
ParameterDefinition(
|
|
71
|
+
name="column",
|
|
72
|
+
label="Column",
|
|
73
|
+
type=ParameterType.COLUMN,
|
|
74
|
+
required=True,
|
|
75
|
+
description="Column containing ISBN values",
|
|
76
|
+
),
|
|
77
|
+
ParameterDefinition(
|
|
78
|
+
name="format",
|
|
79
|
+
label="ISBN Format",
|
|
80
|
+
type=ParameterType.SELECT,
|
|
81
|
+
options=[
|
|
82
|
+
{"value": "any", "label": "Any (ISBN-10 or ISBN-13)"},
|
|
83
|
+
{"value": "isbn10", "label": "ISBN-10 Only"},
|
|
84
|
+
{"value": "isbn13", "label": "ISBN-13 Only"},
|
|
85
|
+
],
|
|
86
|
+
default="any",
|
|
87
|
+
description="Expected ISBN format",
|
|
88
|
+
),
|
|
89
|
+
],
|
|
90
|
+
tags=["business_rule", "isbn", "book", "identifier"],
|
|
91
|
+
severity_default="medium",
|
|
92
|
+
),
|
|
93
|
+
ValidatorDefinition(
|
|
94
|
+
name="CreditCard",
|
|
95
|
+
display_name="Credit Card Number",
|
|
96
|
+
category=ValidatorCategory.BUSINESS_RULE,
|
|
97
|
+
description="Validates credit card numbers using Luhn algorithm and format checks.",
|
|
98
|
+
parameters=[
|
|
99
|
+
ParameterDefinition(
|
|
100
|
+
name="column",
|
|
101
|
+
label="Column",
|
|
102
|
+
type=ParameterType.COLUMN,
|
|
103
|
+
required=True,
|
|
104
|
+
description="Column containing credit card numbers",
|
|
105
|
+
),
|
|
106
|
+
ParameterDefinition(
|
|
107
|
+
name="card_type",
|
|
108
|
+
label="Card Type",
|
|
109
|
+
type=ParameterType.MULTI_SELECT,
|
|
110
|
+
options=[
|
|
111
|
+
{"value": "visa", "label": "Visa"},
|
|
112
|
+
{"value": "mastercard", "label": "MasterCard"},
|
|
113
|
+
{"value": "amex", "label": "American Express"},
|
|
114
|
+
{"value": "discover", "label": "Discover"},
|
|
115
|
+
{"value": "jcb", "label": "JCB"},
|
|
116
|
+
{"value": "diners", "label": "Diners Club"},
|
|
117
|
+
],
|
|
118
|
+
description="Accepted card types (empty = any)",
|
|
119
|
+
),
|
|
120
|
+
],
|
|
121
|
+
tags=["business_rule", "credit_card", "payment", "financial"],
|
|
122
|
+
severity_default="critical",
|
|
123
|
+
),
|
|
124
|
+
ValidatorDefinition(
|
|
125
|
+
name="IBAN",
|
|
126
|
+
display_name="International Bank Account Number",
|
|
127
|
+
category=ValidatorCategory.BUSINESS_RULE,
|
|
128
|
+
description="Validates International Bank Account Numbers (IBAN).",
|
|
129
|
+
parameters=[
|
|
130
|
+
ParameterDefinition(
|
|
131
|
+
name="column",
|
|
132
|
+
label="Column",
|
|
133
|
+
type=ParameterType.COLUMN,
|
|
134
|
+
required=True,
|
|
135
|
+
description="Column containing IBAN values",
|
|
136
|
+
),
|
|
137
|
+
ParameterDefinition(
|
|
138
|
+
name="country_codes",
|
|
139
|
+
label="Allowed Country Codes",
|
|
140
|
+
type=ParameterType.STRING_LIST,
|
|
141
|
+
description="Allowed country codes (e.g., DE, FR, GB). Empty = any.",
|
|
142
|
+
placeholder="DE, FR, GB",
|
|
143
|
+
),
|
|
144
|
+
],
|
|
145
|
+
tags=["business_rule", "iban", "bank", "financial"],
|
|
146
|
+
severity_default="high",
|
|
147
|
+
),
|
|
148
|
+
ValidatorDefinition(
|
|
149
|
+
name="VAT",
|
|
150
|
+
display_name="VAT Number Validation",
|
|
151
|
+
category=ValidatorCategory.BUSINESS_RULE,
|
|
152
|
+
description="Validates Value Added Tax (VAT) identification numbers.",
|
|
153
|
+
parameters=[
|
|
154
|
+
ParameterDefinition(
|
|
155
|
+
name="column",
|
|
156
|
+
label="Column",
|
|
157
|
+
type=ParameterType.COLUMN,
|
|
158
|
+
required=True,
|
|
159
|
+
description="Column containing VAT numbers",
|
|
160
|
+
),
|
|
161
|
+
ParameterDefinition(
|
|
162
|
+
name="country",
|
|
163
|
+
label="Country",
|
|
164
|
+
type=ParameterType.SELECT,
|
|
165
|
+
options=[
|
|
166
|
+
{"value": "auto", "label": "Auto-detect"},
|
|
167
|
+
{"value": "DE", "label": "Germany"},
|
|
168
|
+
{"value": "FR", "label": "France"},
|
|
169
|
+
{"value": "GB", "label": "United Kingdom"},
|
|
170
|
+
{"value": "IT", "label": "Italy"},
|
|
171
|
+
{"value": "ES", "label": "Spain"},
|
|
172
|
+
{"value": "NL", "label": "Netherlands"},
|
|
173
|
+
{"value": "BE", "label": "Belgium"},
|
|
174
|
+
{"value": "AT", "label": "Austria"},
|
|
175
|
+
{"value": "PL", "label": "Poland"},
|
|
176
|
+
],
|
|
177
|
+
default="auto",
|
|
178
|
+
description="VAT number country format",
|
|
179
|
+
),
|
|
180
|
+
],
|
|
181
|
+
tags=["business_rule", "vat", "tax", "eu"],
|
|
182
|
+
severity_default="high",
|
|
183
|
+
),
|
|
184
|
+
ValidatorDefinition(
|
|
185
|
+
name="SWIFT",
|
|
186
|
+
display_name="SWIFT/BIC Code Validation",
|
|
187
|
+
category=ValidatorCategory.BUSINESS_RULE,
|
|
188
|
+
description="Validates SWIFT/BIC bank identification codes.",
|
|
189
|
+
parameters=[
|
|
190
|
+
ParameterDefinition(
|
|
191
|
+
name="column",
|
|
192
|
+
label="Column",
|
|
193
|
+
type=ParameterType.COLUMN,
|
|
194
|
+
required=True,
|
|
195
|
+
description="Column containing SWIFT/BIC codes",
|
|
196
|
+
),
|
|
197
|
+
ParameterDefinition(
|
|
198
|
+
name="format",
|
|
199
|
+
label="Code Format",
|
|
200
|
+
type=ParameterType.SELECT,
|
|
201
|
+
options=[
|
|
202
|
+
{"value": "any", "label": "Any (8 or 11 characters)"},
|
|
203
|
+
{"value": "bic8", "label": "BIC8 (8 characters)"},
|
|
204
|
+
{"value": "bic11", "label": "BIC11 (11 characters)"},
|
|
205
|
+
],
|
|
206
|
+
default="any",
|
|
207
|
+
description="Expected SWIFT/BIC format",
|
|
208
|
+
),
|
|
209
|
+
],
|
|
210
|
+
tags=["business_rule", "swift", "bic", "bank", "financial"],
|
|
211
|
+
severity_default="medium",
|
|
212
|
+
),
|
|
213
|
+
ValidatorDefinition(
|
|
214
|
+
name="EAN",
|
|
215
|
+
display_name="EAN/UPC Barcode Validation",
|
|
216
|
+
category=ValidatorCategory.BUSINESS_RULE,
|
|
217
|
+
description="Validates EAN-8, EAN-13, UPC-A, or UPC-E barcodes.",
|
|
218
|
+
parameters=[
|
|
219
|
+
ParameterDefinition(
|
|
220
|
+
name="column",
|
|
221
|
+
label="Column",
|
|
222
|
+
type=ParameterType.COLUMN,
|
|
223
|
+
required=True,
|
|
224
|
+
description="Column containing barcode values",
|
|
225
|
+
),
|
|
226
|
+
ParameterDefinition(
|
|
227
|
+
name="format",
|
|
228
|
+
label="Barcode Format",
|
|
229
|
+
type=ParameterType.SELECT,
|
|
230
|
+
options=[
|
|
231
|
+
{"value": "any", "label": "Any (EAN/UPC)"},
|
|
232
|
+
{"value": "ean8", "label": "EAN-8"},
|
|
233
|
+
{"value": "ean13", "label": "EAN-13"},
|
|
234
|
+
{"value": "upca", "label": "UPC-A"},
|
|
235
|
+
{"value": "upce", "label": "UPC-E"},
|
|
236
|
+
],
|
|
237
|
+
default="any",
|
|
238
|
+
description="Expected barcode format",
|
|
239
|
+
),
|
|
240
|
+
],
|
|
241
|
+
tags=["business_rule", "ean", "upc", "barcode", "product"],
|
|
242
|
+
severity_default="medium",
|
|
243
|
+
),
|
|
244
|
+
]
|