# Example: Validation Utilities (Pattern 2 - Function-Based Workflow)

Demonstrates Pattern 2 (Function-Based Workflow) providing a library of validation functions that callers invoke as needed.

```xml
<functions>
  <!-- CRITICAL: Both DoR/DoD check elements below are MANDATORY -->
  <execute_dor_checks_before_starting/>
  <schedule_dod_checks_with_sub_agent_before_starting/>
  
  <function name="validate_yaml_syntax">
    <purpose>Check if a YAML file has valid syntax</purpose>
    <when_to_use>Before processing any YAML configuration or data file</when_to_use>
    <inputs>
      - file_path: Path to the YAML file to validate
    </inputs>
    <action>
      1. Read file content
      2. Parse using YAML parser
      3. Capture any syntax errors with line numbers
    </action>
    <constraints>
      - BLOCKING: Return error immediately if file not found
    </constraints>
    <outputs>
      - is_valid: boolean indicating syntax validity
      - errors: list of syntax errors with line numbers (empty if valid)
    </outputs>
  </function>

  <function name="validate_schema_compliance">
    <purpose>Check if data conforms to expected schema structure</purpose>
    <when_to_use>After syntax validation passes, before using data</when_to_use>
    <inputs>
      - data: Parsed data object to validate
      - schema_path: Path to schema definition file
    </inputs>
    <action>
      1. Load schema definition
      2. Traverse data structure
      3. Check each field against schema requirements
      4. Collect all violations
    </action>
    <constraints>
      - CRITICAL: Check required fields first
      - MANDATORY: Validate nested structures recursively
    </constraints>
    <outputs>
      - is_compliant: boolean indicating schema compliance
      - violations: list of schema violations with field paths
    </outputs>
  </function>

  <function name="validate_cross_references">
    <purpose>Verify that references between files are valid</purpose>
    <when_to_use>When validating documents that reference other documents</when_to_use>
    <inputs>
      - source_file: File containing references
      - reference_pattern: Regex pattern to find references
    </inputs>
    <action>
      1. Extract all references from source file
      2. For each reference, check if target exists
      3. Report broken references
    </action>
    <outputs>
      - all_valid: boolean indicating all references valid
      - broken_refs: list of broken references with locations
    </outputs>
  </function>

</functions>
```
