vuetifyjs/vuetify · error · Error

Could not find Vuetify rules injection

Error message

Could not find Vuetify rules injection

What it means

useRules() without an argument reads rule aliases via inject(RulesSymbol). That symbol is provided only by the Vuetify rules plugin (labs/rules/plugin.ts), not by the core createVuetify() install. It throws when useRules() is called in alias-mode and the rules plugin was never installed.

Source

Thrown at packages/vuetify/src/labs/rules/rules.ts:129

  }

  return {
    resolve,
    aliases,
  }
}

export const RulesSymbol: InjectionKey<RulesInstance> = Symbol.for('vuetify:rules')

export function useRules (): RuleAliases
export function useRules (fn: () => ValidationProps['rules']): Readonly<Ref<ValidationProps['rules']>> | Readonly<Ref<ValidationRule[]>>

export function useRules (fn?: () => ValidationProps['rules']) {
  const rules = inject(RulesSymbol, null)

  if (!fn) {
    if (!rules) {
      throw new Error('Could not find Vuetify rules injection')
    }
    return rules.aliases
  }

  return rules?.resolve(fn) ?? toRef(fn)
}

View on GitHub (pinned to 8d153908df)

Solutions

  1. Install the rules plugin alongside createVuetify (e.g. app.use(createVuetify({ ...plugins: [rules] })) per the labs setup).
  2. If you do not need aliases, call useRules(fn) with a function so it falls back to toRef(fn) when the symbol is absent.
  3. Register the plugin in the test app as well.

Example fix

// before
app.use(createVuetify())

// after
app.use(createVuetify({ plugins: [rules] }))
Defensive patterns

Strategy: validation

Validate before calling

import { inject } from 'vue'
import { RulesSymbol } from 'vuetify/labs/rules'
const rules = inject(RulesSymbol, null)
if (!rules) {
  // rules plugin absent: do not use alias-mode useRules(); pass a fn instead.
}

Type guard

import { inject } from 'vue'
import { RulesSymbol } from 'vuetify/labs/rules'
export function hasRules (): boolean {
  return inject(RulesSymbol, null) != null
}

Prevention

When it happens

Trigger: Calling useRules() (no argument) on an app that installed createVuetify() but not the rules plugin; using a component that consumes rule aliases without the plugin.

Common situations: Adopting the labs rules feature without registering its plugin; assuming rules ship with core Vuetify; test app that only adds createVuetify().

Related errors


AI-assisted analysis of vuetifyjs/vuetify@8d153908df (2026-08-12). Data as JSON: /api/errors/857320234beafc4e. Report an issue: GitHub.