This directory contains runnable examples for the full Exdantic surface area: core validation, runtime schema generation, model-level logic, and LLM/DSPy integration workflows.
Prerequisites
- Run commands from the repository root.
- Install dependencies once:
mix deps.get - Optional (faster repeated runs):
mix compile
Running Examples
Run a single example:
# Mix-based example
mix run examples/basic_usage.exs
# Standalone example that uses Mix.install
elixir examples/runtime_schema.exs
Execution rule:
- If a script contains
Mix.install(...), run it withelixir. - Otherwise, run it with
mix run.
Run everything:
bash examples/run_all.sh
Useful flags:
# Run only examples whose filename contains "llm"
bash examples/run_all.sh --match llm
# Stop immediately on first failure
bash examples/run_all.sh --fail-fast
Complete Example Catalog
| Script | Focus | Runner |
|---|---|---|
advanced_config.exs | Configuration presets, merging, builder pattern, and validation behavior tuning | elixir |
advanced_features.exs | Advanced type modeling, nested object validation, and integration-style patterns | mix run |
basic_usage.exs | Core Exdantic concepts: primitive/complex types, constraints, and errors | mix run |
computed_fields.exs | Computed fields with dependencies, transformations, and JSON Schema behavior | mix run |
conditional_recursive_validation.exs | Conditional logic, recursive schemas, dynamic schema selection, and validation pipelines | mix run |
custom_validation.exs | Custom validator functions for business rules and value transformation | mix run |
dspy_integration.exs | End-to-end DSPy-style patterns (runtime models, wrappers, retries, provider schema handling) | elixir |
enhanced_validator.exs | Universal validation interface across compiled schemas, runtime schemas, and type specs | elixir |
field_metadata_dspy.exs | Field metadata annotations and DSPy-style input/output field processing | mix run |
json_schema_resolver.exs | $ref resolution, flattening, and provider-oriented schema optimization | elixir |
llm_integration.exs | Structured LLM output validation, signatures, quality checks, and dynamic schema selection | mix run |
llm_pipeline_orchestration.exs | Multi-stage LLM validation pipeline design, error handling, and quality assessment | mix run |
model_validators.exs | Cross-field and model-level validation with complex domain rules | mix run |
readme_examples.exs | Verifies README snippets by executing them as a consistency check | mix run |
root_schema.exs | Root-level validation for non-map data (arrays, unions, primitives) | mix run |
runtime_schema.exs | Dynamic schema creation and validation at runtime | elixir |
settings_loader.exs | End-to-end environment settings loading: prefixes, overrides, nested exploded keys, and error handling | mix run |
type_adapter.exs | TypeAdapter-based runtime validation, coercion, dumping, and batch use | elixir |
wrapper_models.exs | Wrapper model patterns for single-field validation and reuse | elixir |
Suggested Learning Order
basic_usage.exsadvanced_features.exscustom_validation.exsmodel_validators.exscomputed_fields.exsruntime_schema.exstype_adapter.exswrapper_models.exsroot_schema.exsenhanced_validator.exsjson_schema_resolver.exsdspy_integration.exsllm_integration.exsllm_pipeline_orchestration.exsfield_metadata_dspy.exsconditional_recursive_validation.exsadvanced_config.exssettings_loader.exsreadme_examples.exs
Notes
- Many scripts intentionally print extensive output and benchmark-style timings.
- Some examples compile temporary modules at runtime; repeated runs are expected to be noisy.
run_all.shreports pass/fail per file and returns a non-zero exit code if any example fails.