code: def validate(
      schema: Type[BaseModel], obj: Dict[str, Any]
  ) -> List[str]:
      """Validate data against a given pydantic schema.
  
      obj (Dict[str, Any]): JSON-serializable data to validate.
      schema (pydantic.BaseModel): The schema to validate against.
      RETURNS (List[str]): A list of error messages, if available.
      """
      try:
          schema(**obj)
          return []
      except ValidationError as e:
          errors = e.errors()
          data = defaultdict(list)
          for error in errors:
              err_loc = " -> ".join(
                  [str(p) for p in error.get("loc", [])]
              )
              data[err_loc].append(error.get("msg"))
          return [
              f"[{loc}] {', '.join(msg)}" for loc, msg in data.items()
          ]
  
imports: import inspect
  import re
  from collections import defaultdict
  from enum import Enum
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union
  from thinc.api import ConfigValidationError, Model, Optimizer
  from thinc.config import Promise
  from .attrs import NAMES
  from .compat import Literal
  from .lookups import Lookups
  from .util import is_cython_func
label_desc: Use image node_id 1 for calling a global function with example usage: validate(schema, obj) and returns: list, unknown