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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mdxh/vee-validate

v0.1.0

Published

Install vee-validate to vue3 using dxh wrapper

Downloads

1

Readme

@mdxh/vee-validate

Install VeeValidate to vue3 using dxh wrapper

Usage

Installation

Just use the below command to install VeeValidate.

npm i @mdxh/vee-validate@latest

This command will install vee-validate and @vee-validate/rules automatically.

Plugin Configaration with validation rules

You can add below code to main.ts:

import { defineRule, configure } from 'vee-validate'
import { all } from '@vee-validate/rules'

type ValidationMessages = {
  [key: string]: string;
};

Object.entries(all).forEach(([name, rule]) => {
  defineRule(name, rule)
})

defineRule("phone", (value: any) => {
  const regex = /^\+?[0-9](?:[0-9 ]{5,}[0-9])$/;
  if (regex.test(value)) {
    return true;
  }
  return "The field must be a valid phone number.";
});

configure({
  bails: false,
  validateOnInput: true,
  validateOnBlur: true,
  validateOnChange: true,
  generateMessage: (context) => {
    const field = context.label || context.field;
    const ruleName = context.rule?.name;
    const params = (context.rule?.params as unknown[]) || [];

    const messages: ValidationMessages = {
      required: `The field ${field} is required.`,
      email: `The field ${field} must be a valid email.`,
      alpha: `The field ${field} may only contain alphabetic characters`,
      alpha_dash: `The field ${field} may contain alpha-numeric characters as well as dashes and underscores`,
      alpha_num: `The field ${field} may only contain alpha-numeric characters`,
      alpha_spaces: `The field ${field} may only contain alphabetic characters and spaces`,
      between: `The field ${field} must be between ${params[0]} and ${params[1]}`,
      confirmed: `The field ${field} does not match`,
      digits: `The field ${field} must be numeric and exactly contain ${params[0]} digits`,
      dimensions: `The field ${field} must be between ${params[0]} and ${params[1]} pixels`,
      not_one_of: `The field ${field} contains an invalid value`,
      ext: `The field ${field} must have a valid file extension`,
      image: `The field ${field} must be an image`,
      one_of: `The field ${field} must be one of the allowed values`,
      integer: `The field ${field} must be an integer`,
      is: `The field ${field} must be ${params[0]}`,
      is_not: `The field ${field} must not be ${params[0]}`,
      length: `The field ${field} must be exactly ${params[0]} characters long`,
      max: `The field ${field} may not be greater than ${params[0]} characters`,
      max_value: `The field ${field} must be ${params[0]} or less`,
      mimes: `The field ${field} must have a valid MIME type`,
      min: `The field ${field} must be at least ${params[0]} characters`,
      min_value: `The field ${field} must be ${params[0]} or more`,
      numeric: `The field ${field} may only contain numeric characters`,
      regex: `The field ${field} format is invalid`,
      size: `The field ${field} size must be less than ${params[0]}KB`,
      url: `The field ${field} must be a valid URL`,
    };

    if (ruleName && messages[ruleName]) {
      return messages[ruleName];
    }

    return `The field ${field} is invalid.`;
  },
});

Now you can use VeeValidate in your components

Start your project

npm run dev

VeeValidate Documentation

See VeeValidate Documentation.

See VeeValidate Global Rules.