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

    LangChain Assistant

    Ask a question to get started

    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 v0.1

    validate_input_variables

    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.

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

    Example:

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

    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.

    View source on GitHub