LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    โŒ˜I

    Chat LangChain

    What can I help with?

    Enter to sendยทShift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coreutilsformattingStrictFormattervalidate_input_variables
    Methodโ—Since v1.8

    validate_input_variables

    Copy
    validate_input_variables(
      self,
      format_string: str,
      input_variables: list[str]
    ) -> None
    View source on GitHub

    Parameters

    NameTypeDescription
    format_string*str

    A string containing replacement fields to validate against (e.g., 'Hello, {name}!').

    input_variables*list[str]

    List of variable names expected to fill the replacement fields.

    Validate that input variables match the placeholders in a format string.

    Checks that the provided input variables can be used to format the given string without missing or extra keys. This is useful for validating prompt templates before runtime.

    Example:

    fmt = StrictFormatter() fmt.validate_input_variables("Hello, {name}!", ["name"]) # OK fmt.validate_input_variables("Hello, {name}!", ["other"]) # Raises