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

react-form-validator-hook-wang

v0.1.1

Published

轻量级 React 表单验证 Hook,支持必填、邮箱、手机号、长度/数值限制等常用验证规则

Downloads

172

Readme

react-form-validator-hook

轻量级 React 表单验证 Hook,无需繁琐的手写验证逻辑,支持常见验证规则,开箱即用。 支持常见验证规则:必填、邮箱格式、手机号、最小 / 最大值、最小 / 最大长度、自定义正则; 实时验证:输入时自动校验,失去焦点时强化校验; 错误提示:自定义错误文案,支持多语言(基础版); 一键校验整个表单:提交时验证所有字段; 轻量无依赖:仅依赖 React,体积 < 5KB。

使用该 React 表单验证 npm 包时,先在 React 项目中通过npm install react-form-validator-hook完成安装,项目需提前有 React16.8+ 环境;之后在表单组件中引入包的useFormValidatorHook,配置包含字段初始值、验证规则的formConfig,也可自定义错误文案,调用 Hook 解构出表单值values、错误信息errors、事件处理handleChange/handleBlur、全量验证validateAll和重置reset等方法;将values绑定到表单输入框的valuehandleChange/handleBlur绑定到onChange/onBlur,错误信息根据errors按需渲染,表单提交时调用validateAll做全量验证,验证通过后即可执行接口请求等业务逻辑,该 Hook 支持必填、邮箱、手机号、长度/数值限制、自定义正则等多种验证规则,可灵活组合满足各类表单验证需求。

安装

npm install react-form-validator-hook
# 或
yarn add react-form-validator-hook