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

element-plus-validate-rules

v1.0.4

Published

[![NPM version](https://img.shields.io/npm/v/element-plus-validate-rules?color=a1b858&label=)](https://www.npmjs.com/package/element-plus-validate-rules)

Downloads

23

Readme

element-plus-validate-rules

NPM version

基于 Element-Plus-Form 的表单验证规则

Installation

  pnpm install element-plus-validate-rules

Usage

<script lang="ts" setup>
import { ElForm, ElFormItem, ElInput } from 'element-plus'
import type { FormRules } from 'element-plus'
import Rules from 'element-plus-validate-rules'

const ruleForm = reactive<{ nickname: string }>({
  nickname: '',
})
const rules: FormRules = [
  {
    nickname: [
      ...Rules.str({
        required: true,
        max: 64,
        name: '昵称',
      }),
    ],
  }
]
</script>

<template>
  <ElForm
    ref="ruleFormRef"
    :model="ruleForm"
    :rules="rules"
    label-width="auto"
    status-icon
  >
      <ElFormItem label="昵称" prop="nickname">
        <ElInput v-model="ruleForm.nickname" placeholder="昵称" />
      </ElFormItem>
  </ElForm>
</template>

内置Properties

公共配置项

| Name | Type | Desc | | :--: | :--: | :--: | | required | boolean | 是否必填 | | name | string | 字段名称 | | max | number | 最大长度 | | min | number | 最小长度 | | len | number | 长度 | | message | string | 校验不通过时显示的信息, 会替代默认信息 | | validator | Function | 自定义验证函数, 与 Element-Plus-Form 相同 |

更多配置项请参考 async-validator

str

字符验证

| Name | Type | Desc | 是否必填 | | :--: | :--: | :--: | :--: | | required | boolean | 是否必填 | 是 |

select

选择(下拉框)验证

| Name | Type | Desc | 是否必填 | | :--: | :--: | :--: | :--: | | multiple | boolean | 是否为多选 | 否 |

decimal

| Name | Type | Desc | 是否必填 | | :--: | :--: | :--: | :--: | | precision | number | 精度 | 否 |

小数类型验证, 精度默认为0, 即整数

int

整数类型验证

numberStr

内容为纯数字的string类型验证

mobile

手机号验证

password

密码验证, 目前验证规则为 至少八个字符, 至少一个字母, 一个数字和一个特殊字符

tel

固定电话验证

time

WIP

时间类型验证

License

MIT License © 2022 cymYoung