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

  1. Run commands from the repository root.
  2. Install dependencies once:
    mix deps.get
    
  3. 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 with elixir.
  • 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

ScriptFocusRunner
advanced_config.exsConfiguration presets, merging, builder pattern, and validation behavior tuningelixir
advanced_features.exsAdvanced type modeling, nested object validation, and integration-style patternsmix run
basic_usage.exsCore Exdantic concepts: primitive/complex types, constraints, and errorsmix run
computed_fields.exsComputed fields with dependencies, transformations, and JSON Schema behaviormix run
conditional_recursive_validation.exsConditional logic, recursive schemas, dynamic schema selection, and validation pipelinesmix run
custom_validation.exsCustom validator functions for business rules and value transformationmix run
dspy_integration.exsEnd-to-end DSPy-style patterns (runtime models, wrappers, retries, provider schema handling)elixir
enhanced_validator.exsUniversal validation interface across compiled schemas, runtime schemas, and type specselixir
field_metadata_dspy.exsField metadata annotations and DSPy-style input/output field processingmix run
json_schema_resolver.exs$ref resolution, flattening, and provider-oriented schema optimizationelixir
llm_integration.exsStructured LLM output validation, signatures, quality checks, and dynamic schema selectionmix run
llm_pipeline_orchestration.exsMulti-stage LLM validation pipeline design, error handling, and quality assessmentmix run
model_validators.exsCross-field and model-level validation with complex domain rulesmix run
readme_examples.exsVerifies README snippets by executing them as a consistency checkmix run
root_schema.exsRoot-level validation for non-map data (arrays, unions, primitives)mix run
runtime_schema.exsDynamic schema creation and validation at runtimeelixir
settings_loader.exsEnd-to-end environment settings loading: prefixes, overrides, nested exploded keys, and error handlingmix run
type_adapter.exsTypeAdapter-based runtime validation, coercion, dumping, and batch useelixir
wrapper_models.exsWrapper model patterns for single-field validation and reuseelixir

Suggested Learning Order

  1. basic_usage.exs
  2. advanced_features.exs
  3. custom_validation.exs
  4. model_validators.exs
  5. computed_fields.exs
  6. runtime_schema.exs
  7. type_adapter.exs
  8. wrapper_models.exs
  9. root_schema.exs
  10. enhanced_validator.exs
  11. json_schema_resolver.exs
  12. dspy_integration.exs
  13. llm_integration.exs
  14. llm_pipeline_orchestration.exs
  15. field_metadata_dspy.exs
  16. conditional_recursive_validation.exs
  17. advanced_config.exs
  18. settings_loader.exs
  19. readme_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.sh reports pass/fail per file and returns a non-zero exit code if any example fails.