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 🙏

© 2025 – Pkg Stats / Ryan Hefner

angular-commons-validator

v1.0.2

Published

angular validate

Readme

angularJs 常用验证指令集合

指令列表

  • chineseLength
指令叙述:验证文字长度(区分全角和半角)一个全角占二个长度,一个半角占一个长度
$scope.test="欠妥欠妥欠工"
<input type="text" chinese-length='10' ng-model="test" />   

此处ng-model处的验证是失败的,$scope.test长度超出10个字符为12个长度


  • chineseName
指令叙述:验证输入字符串的合法性(汉字、下划线、英文字母)
    <script>
        function test($scope){
          $scope.v="hello@@@"
        }
        
    </script>
  
    <input type="text" ng-model="v" chinese-name />

此处ng-model处验证是失败的,chinese-name指令只允许出现汉字、下划线、英文字


  • dTrigger
指令叙述:当鼠标在此指令上失去焦点后,此指把当前指令的ngModel的$dirty值改为true,为了实现鼠标失去焦点时,显示验证信息
   <form name="form1">
       <input type="text" ng-model="v" d-trigger name="test"  required />
   </form>
   相应的在input下方需要使用ng-if表格式来控制验证信息是否显示(采用ngMessages)
   <div ng-messages="form1.test.$erorr" ng-if=form1.test.$dirty>
        <div ng-message="required">此项必填</div>
   </div>
   

示例中当第一次进入页面时,错误验证信息不会显示 ,当鼠标在input上失去焦点后,验证信息显示,注意ng-if的使用


  • formatter-t
指令叙述:禁止输入非数字字符(输入无效),对任何合法的且小于配置中 config.max 的数据四舍五入的保留 config.size 位小数
   
    <form name="form1">
       <input type="text" ng-model="v" formatters-t='{"size":5,max:100000000}' name="test" />
   
   </form>

此文本框用过formatters-t的指令后,当鼠标失去焦点后,会保留5位小数据,当输入的值超过100000000时,不出任何处理

配置文件

config={size:2,max:10000}
config.size:小数据点保留的长度
config.max:最大数

  • end