npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@validex/nuxt

v1.0.3

Published

Nuxt module for validex — auto-imports all rules and composables

Readme

@validex/nuxt

npm version npm downloads build TypeScript 5.0+ license MIT

Nuxt module for validex — auto-imports all 25 validation rules and the useValidation composable.



Prerequisites

@validex/core and zod must be installed as peer dependencies. @nuxt/kit and vue are also peer dependencies but are typically already present in any Nuxt project.

Install

pnpm add @validex/core @validex/nuxt zod

Nuxt Module Setup

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@validex/nuxt'],
  validex: {
    rules: {
      email: { blockDisposable: true },
      password: { length: { min: 10 } },
    },
  },
})

Module Options

interface ValidexNuxtOptions {
  rules?: GlobalConfig['rules']   // Per-rule defaults (same as setup({ rules }))
  i18n?: {
    enabled?: boolean             // Enable i18n key mode
    prefix?: string               // Key prefix (default: 'validation')
    separator?: string            // Key separator (default: '.')
    pathMode?: 'semantic' | 'key' | 'full' | PathTransform
  }
  preload?: PreloadOptions        // Data files to preload at startup
}

Standalone Setup

For use outside of the Nuxt module system (e.g., in a plugin):

// plugins/validex.ts
import { setupValidex } from '@validex/nuxt'

await setupValidex({
  rules: {
    email: { blockDisposable: true },
  },
  preload: {
    disposable: true,
    passwords: 'basic',
  },
})

useValidation Composable

Returns reactive Vue refs that automatically trigger template re-renders when validation state changes.

import { useValidation } from '@validex/nuxt'
import { Email, Password } from '@validex/core'
import { z } from 'zod'

const schema = z.object({
  email: Email(),
  password: Password(),
})

const {
  validate,    // (data: unknown) => Promise<ValidationResult<T>>
  clearErrors, // () => void — resets all errors
  errors,      // ShallowRef<Record<string, readonly string[]>>
  firstErrors, // ShallowRef<Record<string, string>>
  isValid,     // ShallowRef<boolean>
  data,        // ShallowRef<T | undefined>
} = useValidation(schema)

await validate({ email: '[email protected]', password: 'Str0ng!Pass' })
// errors, firstErrors, isValid, data are reactive shallow refs
// Templates re-render automatically when they change
<script setup lang="ts">
import { useValidation } from '@validex/nuxt'
import { Email, Password } from '@validex/core'
import { z } from 'zod'

const schema = z.object({
  email: Email(),
  password: Password(),
})

const formData = reactive({ email: '', password: '' })

const { validate, clearErrors, firstErrors, isValid } = useValidation(schema)

async function onSubmit(data: Record<string, unknown>) {
  clearErrors()
  await validate(data)
  // isValid and firstErrors refs update automatically
}
</script>

<template>
  <form @submit.prevent="onSubmit(formData)">
    <input v-model="formData.email" />
    <span v-if="firstErrors.email" class="error">
      {{ firstErrors.email }}
    </span>

    <input v-model="formData.password" type="password" />
    <span v-if="firstErrors.password" class="error">
      {{ firstErrors.password }}
    </span>

    <button :disabled="!isValid">Submit</button>
  </form>
</template>

Auto-Imports

When used as a Nuxt module, the following are auto-imported (no explicit import needed):

  • All 25 rules: Email, Password, PasswordConfirmation, PersonName, BusinessName, Phone, Website, Url, Username, Slug, PostalCode, LicenseKey, Uuid, Jwt, DateTime, Token, Text, Country, Currency, Color, CreditCard, Iban, VatNumber, MacAddress, IpAddress
  • validate — core validation function
  • validexSetupsetup() from @validex/core, aliased to avoid conflict with Nuxt's own setup
  • useValidation — composable for validation state management

Preloading Data

Preload async data files at startup so first validation has no delay:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@validex/nuxt'],
  validex: {
    preload: {
      disposable: true,
      passwords: 'moderate',
      phone: 'mobile',
      countryCodes: true,
    },
  },
})

i18n Integration

Automatically detects @nuxtjs/i18n and enables translation mode. No extra configuration needed:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxtjs/i18n', '@validex/nuxt'],
  // validex i18n is auto-enabled when @nuxtjs/i18n is present
})

To configure manually:

export default defineNuxtConfig({
  modules: ['@validex/nuxt'],
  validex: {
    i18n: {
      enabled: true,
      prefix: 'validation',
      separator: '.',
    },
  },
})

Documentation

License

MIT