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

ant-design-vue_validateform

v1.2.2

Published

easy used

Readme

ant-design-vue_validateForm

介绍: 基于 ant-desing-vue 的表单校验复杂度进行封装简化(目前支持非空校验和函数校验)

安装

npm install ant-design-vue_validateform --save

使用

1.首先引入 mixin 并且使用

import { validateMixin } from "ant-design-vue_validateform";
export default {
  mixins: [validateMixin]
};

2.其次赋值 form 给当前引用组件的 form 元素(ant-design-vue_validateform 中已经注册了 form,直接用就可以)

 <a-form :form="form">

3.使用校验表单组件(其中 validateInput 和 form 均以存在不需要重新注册)

  <validateFormItem
    :form="form"
    :valiateProps="rules"
    @validate="validateInput"
  />

4.data 中注册 rules, type 类型为 input|| select || datePicker || rangePicker || checkboxGroup,rules 中的每一项的 key 必须与内部的 label 保持一致

rules: {
        test: {
          type: 'input', // 校验的组件类型
          label: 'test', // 与key需要保持一致
          labelName: '测试', // label显示的名称
          message: '请填写', // 校验触发的时候展示的文案
          value: '', // 默认传递的值
          validateStatus: false // 默认需要传递false
        }
      }

5.获取校验后的数据, this.validateOk 是我们插件中已经注册的方法,直接使用后会返回两个回调参数 validate 是校验结果,obj 是通过传递的 rules 返回的值, 例如 4 时候的数据,obj = {grade: value, ....},这样方便我们获取 key 以及 value 来进行接口参数组装以及传递

this.validateOk((validate, obj) => {
  if (!validate) {
    console.log("校验未通过");
  } else {
    console.log(obj); // {grade: '123'}
  }
});

6.新增回到函数校验,需要手动注册 validator 函数,然后在我们的 rules 中进行传递,那么当我们输入或者其他操作的时候将会按照新的函数执行校验操作,具体代码如下

validater(rules, value, calllback) {
  if (/111/.test(value)) {
    calllback("错误了你"); // 将会以此文案进行提示
  } else {
    calllback(); // 使用默认文案提示
  }
}
rules: {
        test: {
          type: 'input', // 校验的组件类型
          label: 'test', // 与key需要保持一致
          labelName: '测试', // label显示的名称
          message: '请填写', // 校验触发的时候展示的文案
          value: '', // 默认传递的值
          validateStatus: false, // 默认需要传递false
          validater: this.validater
        }
      }