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

vuetify_rules

v1.0.0

Published

Rules and functions necessary to validate forms in vuetify

Readme

vuetify_rules

npm version npm downloads npm total downloads Documentation Node.js CI License: GPL-3.0

Validation rules and helper utility functions for Vuetify forms with dynamic internationalization (i18n) support and zero runtime dependencies.

📖 Full API Documentation & Examples


Features

  • ⚡ Zero Runtime Dependencies: Ultra-lightweight bundle size, ideal for Vite and modern web bundlers.
  • Vuetify Ready: Form validation rules designed for v-text-field, v-select, v-file-input, etc.
  • 🌐 Reactive Multi-Language (i18n): Switch languages dynamically at runtime (en, es, fr included, extensible with addTranslations).
  • 🔷 Full TypeScript Support: Comprehensive type definitions (index.d.ts) with JSDoc descriptions and autocompletion for VS Code / WebStorm.
  • 🛠️ Rich Utility Library: Helper functions for ISO date parsing, numeric rounding, decimal counting, Map conversions, and array-of-objects (aoo_*) calculations.

Installation

npm install vuetify_rules

Documentation

Full interactive API documentation generated with TypeDoc is available at:

👉 https://turulomio.github.io/vuetify_rules/


Quick Start

1. Form Validation with Vuetify

<template>
  <v-form v-model="valid">
    <!-- Integer rule: max 6 digits, required -->
    <v-text-field
      v-model.number="age"
      label="Age"
      :rules="RulesInteger(6, true)"
    />

    <!-- Float rule: max 8 digits, required, max 2 decimals -->
    <v-text-field
      v-model.number="price"
      label="Price"
      :rules="RulesFloat(8, true, 2)"
    />

    <!-- Float Greater than Zero (> 0): max 8 digits, required, max 2 decimals -->
    <v-text-field
      v-model.number="amount"
      label="Positive Amount"
      :rules="RulesFloatGZ(8, true, 2)"
    />

    <!-- General String rule: max 50 characters, optional -->
    <v-text-field
      v-model="description"
      label="Description"
      :rules="RulesString(50, false)"
    />

    <!-- Date ISO string rule: YYYY-MM-DD, required -->
    <v-text-field
      v-model="birthDate"
      label="Birth Date"
      :rules="RulesDateIsoString(true)"
    />

    <!-- Email rule: required -->
    <v-text-field
      v-model="email"
      label="Email Address"
      :rules="RulesEmail(true)"
    />
  </v-form>
</template>

<script setup>
import { ref } from 'vue';
import {
  RulesInteger,
  RulesFloat,
  RulesFloatGZ,
  RulesString,
  RulesDateIsoString,
  RulesEmail,
  singleton
} from 'vuetify_rules';

const valid = ref(false);
const age = ref(null);
const price = ref(null);
const amount = ref(null);
const description = ref('');
const birthDate = ref('');
const email = ref('');
</script>

2. Changing Language Dynamically

Rules automatically re-evaluate with the active language without needing page reloads:

import { singleton } from 'vuetify_rules';

// Switch to Spanish
await singleton.setLanguage('es');

// Switch to French
await singleton.setLanguage('fr');

// Switch back to English
await singleton.setLanguage('en');

// Check current language
console.log(singleton.getLanguage()); // "en"

Adding Custom Translations

You can register or override translation strings at runtime:

singleton.addTranslations('de', {
  'Must be an integer number': 'Muss eine ganze Zahl sein',
  'Invalid Email address': 'Ungültige E-Mail-Adresse',
});

await singleton.setLanguage('de');

3. Utility Functions

vuetify_rules exports a suite of pure helper functions:

import {
  round,
  localtime,
  parseNumber,
  isDateIsoString,
  isDatetimeAwareIsoString,
  aoo_sum,
  aoo_average_ponderated,
  percentage_generic_string
} from 'vuetify_rules';

// High-precision rounding
round(1.005, 2); // 1.01

// String / number parsing with comma support
parseNumber("12,34"); // 12.34

// ISO date and datetime validations
isDateIsoString("2026-09-05"); // true
isDatetimeAwareIsoString("2026-09-05T12:00:00Z"); // true

// Calculations on Arrays of Objects (aoo)
const items = [{ price: 10.5 }, { price: 20.25 }];
aoo_sum(items, 'price'); // 30.75

// Formatting percentages
percentage_generic_string(0.154, 'es-ES', 2); // "15,40 %"

Available Rules Summary

| Rule Generator | Description | | :--- | :--- | | RulesInteger(maxdigits, required) | Validates integers with a maximum number of digits. | | RulesFloat(maxdigits, required, maxdecimals) | Validates floating-point numbers with maximum digits and decimal places. | | RulesFloatGZ(maxdigits, required, maxdecimals) | Floating-point number strictly greater than zero (> 0). | | RulesFloatGEZ(maxdigits, required, maxdecimals) | Number greater than or equal to zero (>= 0). | | RulesFloatLEZ(maxdigits, required, maxdecimals) | Number less than or equal to zero (<= 0). | | RulesDateIsoString(required) | Validates calendar dates in ISO format (YYYY-MM-DD). | | RulesDatetimeAwareIsoString(required) | Validates timezone-aware UTC ISO date-times (YYYY-MM-DDTHH:mm:ssZ). | | RulesString(maxdigits, required) | Validates string length up to maxdigits. | | RulesPassword(maxdigits, required) | Validates password string (between 8 and maxdigits characters). | | RulesSelection(required) | Validates selection from dropdowns or select boxes. | | RulesEmail(required) | Validates email address syntax. |

For detailed parameters and return types, see the online API documentation.


Links