Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Sdv dev SDV Custom Constraint Definition

From Leeroopedia
Knowledge Sources
Domains Data_Quality, Extensibility
Last Updated 2026-02-14 00:00 GMT

Overview

An extensibility pattern that allows users to define custom business rule constraints using Python code for scenarios not covered by built-in constraints.

Description

Custom constraint definition enables users to implement arbitrary business logic as constraints by subclassing ProgrammableConstraint. Users define methods for validation, transformation, reverse transformation, and metadata updates. The SDV framework wraps these custom constraints in a ProgrammableConstraintHarness that integrates them into the standard constraint pipeline.

Usage

Use this pattern when built-in constraints (Inequality, FixedCombinations, Range) do not cover the specific business rules needed. Examples include custom validation logic, cross-table constraints, or domain-specific rules.

Theoretical Basis

The pattern follows the strategy pattern, where users implement a standard interface:

  1. validate: Check that metadata is compatible with the constraint
  2. fit: Learn any necessary information from the data
  3. transform: Modify data to encode the constraint
  4. get_updated_metadata: Describe how metadata changes after transformation
  5. reverse_transform: Reconstruct original data format from transformed data
  6. is_valid: Validate that synthetic data satisfies the constraint

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment