---
name: validate_json_schema
kind: function
lang: py
domain: core
version: "1.0.0"
purity: pure
signature: "def validate_json_schema(data: dict, schema: dict) -> tuple[bool, list[str]]"
description: "Valida un dict contra un subset practico de JSON Schema (draft 2020-12) sin dependencias externas. Soporta type, required, properties, items, minItems/maxItems, minimum/maximum, exclusiveMinimum/exclusiveMaximum, minLength/maxLength, pattern, enum. Acumula todos los errores con paths descriptivos."
tags: [validation, schema, json-schema, pure, core]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: [re]
params:
  - name: data
    desc: "Diccionario a validar contra el schema"
  - name: schema
    desc: "Esquema JSON Schema (subset practico)"
output: "Tupla (válido: bool, errores: list[str]) con lista de errores si hay"
tested: true
tests:
  - "schema simple con types y required"
  - "nested object validation"
  - "array con items schema"
  - "pattern validation en strings"
  - "numeric ranges"
  - "multiples errores acumulados con paths correctos"
  - "schema vacio acepta todo"
  - "data none contra required field"
test_file_path: "python/functions/core/validate_json_schema_test.py"
file_path: "python/functions/core/validate_json_schema.py"
---

## Ejemplo

```python
schema = {
    "type": "object",
    "required": ["name", "age"],
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "integer", "minimum": 0},
        "email": {"type": "string", "pattern": r"^[^@]+@[^@]+$"},
    },
}

valid, errors = validate_json_schema({"name": "Alice", "age": 30}, schema)
# valid = True, errors = []

valid, errors = validate_json_schema({"name": 123, "age": -1}, schema)
# valid = False
# errors = [
#   "$.name: expected string, got integer",
#   "$.age: -1 < minimum 0",
#   "$.email: required field missing or empty",  (si email en required)
# ]
```

## Notas

Funcion pura. Solo usa `re` de la stdlib. No cubre el spec completo de JSON Schema — esta disenada para validacion practica de metadata de entities y resultados de queries. El path usa notacion `$.field[i]` para facilitar debugging. Schema vacio acepta cualquier valor (comportamiento estandar JSON Schema).
