Home / Function/ validateVariables() — supabase Function Reference

validateVariables() — supabase Function Reference

Architecture documentation for the validateVariables() function in Partial.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  c4e99cf4_74d4_e55a_d410_f70700102bee["validateVariables()"]
  f759d72f_4789_4f16_671d_55f55b4a2ad9["rewriteNodes()"]
  f759d72f_4789_4f16_671d_55f55b4a2ad9 -->|calls| c4e99cf4_74d4_e55a_d410_f70700102bee
  224f83a6_9322_e59b_55e6_44359e0b9138["extractExpectedVariables()"]
  c4e99cf4_74d4_e55a_d410_f70700102bee -->|calls| 224f83a6_9322_e59b_55e6_44359e0b9138
  style c4e99cf4_74d4_e55a_d410_f70700102bee fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/directives/Partial.ts lines 97–128

function validateVariables(
  content: string,
  vars: Record<string, string> | undefined,
  partialPath: string
) {
  const expectedVars = extractExpectedVariables(content)
  const providedVars = vars ? new Set(Object.keys(vars)) : new Set<string>()

  // Check for missing variables
  const missingVars = [...expectedVars].filter((v) => !providedVars.has(v))
  if (missingVars.length > 0) {
    const varList = missingVars.map((v) => `"${v}"`).join(', ')
    const plural = missingVars.length > 1
    throw new Error(
      `Missing required variable${plural ? 's' : ''} in $Partial "${partialPath}": ${varList}\n` +
        `Expected variable${expectedVars.size > 1 ? 's' : ''}: ${[...expectedVars].map((v) => `"${v}"`).join(', ')}\n` +
        `Provided variable${providedVars.size !== 1 ? 's' : ''}: ${providedVars.size > 0 ? [...providedVars].map((v) => `"${v}"`).join(', ') : 'none'}`
    )
  }

  // Check for unexpected variables
  const unexpectedVars = [...providedVars].filter((v) => !expectedVars.has(v))
  if (unexpectedVars.length > 0) {
    const varList = unexpectedVars.map((v) => `"${v}"`).join(', ')
    const plural = unexpectedVars.length > 1
    throw new Error(
      `Unexpected variable${plural ? 's' : ''} in $Partial "${partialPath}": ${varList}\n` +
        `Expected variable${expectedVars.size !== 1 ? 's' : ''}: ${expectedVars.size > 0 ? [...expectedVars].map((v) => `"${v}"`).join(', ') : 'none'}\n` +
        `Provided variable${plural ? 's' : ''}: ${[...providedVars].map((v) => `"${v}"`).join(', ')}`
    )
  }
}

Subdomains

Called By

Frequently Asked Questions

What does validateVariables() do?
validateVariables() is a function in the supabase codebase.
What does validateVariables() call?
validateVariables() calls 1 function(s): extractExpectedVariables.
What calls validateVariables()?
validateVariables() is called by 1 function(s): rewriteNodes.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free